# How to update a single table cell using ajax

**URL:** <https://www.ruby-forum.com/t/how-to-update-a-single-table-cell-using-ajax/192341>\
**Category:** Rails\
**Created:** [July 28, 2010, 5:30pm UTC](https://www.ruby-forum.com/t/how-to-update-a-single-table-cell-using-ajax/192341 "2010-07-28T17:30:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![techy\_bolek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@techy\_bolek](https://www.ruby-forum.com/u/techy_bolek)\
**Post date:** [July 28, 2010, 5:30pm UTC](https://www.ruby-forum.com/t/how-to-update-a-single-table-cell-using-ajax/192341/1 "2010-07-28T17:30:25Z")

</div>

I’m trying to update a table cell based upon a selection in another cell  
identified as “descPlaceholder”. However, instead of getting the  
intended cell updated the updated string gets displayed completely  
outside of the table in a seemingly arbitrary spot on the form.

The form:

| Code | Name | Quantity |
| --- | --- | --- |
| \<%= select\_tag :partcode, options\_from\_collection\_for\_select(@parts, 'id', 'code') %\> \<%= observe\_field(:partcode, :update =\> :descPlaceholder, :url =\> {:action =\> :getPartName}) %\> | placeholder for description | \<%= text\_field "partquantity", "quantity", :size =\>5, :maxlength =\>5 %\> |

getPartName.html.erb:

Test Description

getPartName method:  
def  
end

---

<div class="post-metadata">

**Author:** ![techy\_bolek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@techy\_bolek](https://www.ruby-forum.com/u/techy_bolek)\
**Post date:** [July 28, 2010, 6:05pm UTC](https://www.ruby-forum.com/t/how-to-update-a-single-table-cell-using-ajax/192341/2 "2010-07-28T18:05:31Z")

</div>

On Wed, Jul 28, 2010 at 8:30 AM, Tomasz R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to update a table cell based upon a selection in another cell  
> identified as “descPlaceholder”. However, instead of getting the  
> intended cell updated the updated string gets displayed completely  
> outside of the table in a seemingly arbitrary spot on the form.

> ```
> </td>
> <div id="descPlaceholder">
> <td>placeholder for description</td>
> </div>
> <td>
> 
> ```

That’ll never work because it’s not valid HTML; a DIV can’t be a child  
of a TR.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![techy\_bolek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@techy\_bolek](https://www.ruby-forum.com/u/techy_bolek)\
**Post date:** [July 29, 2010, 3:00pm UTC](https://www.ruby-forum.com/t/how-to-update-a-single-table-cell-using-ajax/192341/3 "2010-07-29T15:00:37Z")

</div>

You can alwaus just do the following:

---

<div class="post-metadata">

**Author:** ![techy\_bolek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@techy\_bolek](https://www.ruby-forum.com/u/techy_bolek)\
**Post date:** [July 30, 2010, 3:52pm UTC](https://www.ruby-forum.com/t/how-to-update-a-single-table-cell-using-ajax/192341/4 "2010-07-30T15:52:40Z")

</div>

Eric Y. wrote:

> You can alwaus just do the following:
> 
> Wow, many thanks to both of you!
