Imagine a table row like this

<tr>
  <td>
    <select>...</select>
  </td>
  <td>
    <input type="text" ... />
  </td>
  <td>
    <input type="text" ... />
  </td>
  <td>
    <input type="text" ... />
  </td>
  <td>
    ...
  </td>
</tr>



Depending on the select option I need to modify or clear values in the
text inputs in the 2nd, 3rd, and 4th cells.

I find that this code works, but suspect there may be a better way to
achieve the same result with less code?

// Update 2nd column <input> with new_value.
// $(this) is the select in the first row cell.
$
(this).parent('td').parent('tr').children('td').eq(1)children('input').attr("value",new_value);

Since I'll be updating various cells I suppose this helps, but again
suspect there is a better way.
var cells = $(this).parent('td').parent('tr').children('td');
cells.eq(1).children('input').attr("value",new_value_1);
cells.eq(3).children('input').attr("value",new_value_2);
cells.eq(4).children('input').attr("value",new_value_3);

Thanks

Brad

Reply via email to