This is untested and just off the top of my head

$("table tr[id^='row']").each(function () {
       $(this).find("td checkbox").click(function() {
            if ($(this).is(":checked") == true) {
                 var $row = $(this).parent().parent(); //first is
<td>, second is <tr>
                 $row.find("input.contact").val("Your value here");
                 $row.find("input.email").val("Your value here");
            }
       });
});

On Jan 18, 2:41 pm, LexHair <jdpugl...@hotmail.com> wrote:
> I have a table structure with a multiple rows containing a checkbox
> input and 4 text inputs with distinct classes. I want to prefill two
> of the text inputs in the same row where the checkbox is checked.
> Example code for the first two rows:
>
> <table>
>  <tr id="row1">
>    <td><input type="checkbox" /></td>
>    <td><input type="text" class="email" /></td>
>    <td><input type="text" class="contact" /></td>
>    <td><input type="text" class="realname" /></td>
>    <td><input type="text" class="sport" /></td>
>  </tr>
>   <tr id="row2">
>    <td><input type="checkbox" /></td>
>    <td><input type="text" class="email" /></td>
>    <td><input type="text" class="contact" /></td>
>    <td><input type="text" class="realname" /></td>
>    <td><input type="text" class="sport" /></td>
>  </tr>
> </table>
>
> I need help me crafting the correct selector to focus control onto the
> text input for the input with class="contact" and class="email". I can
> write the function to manipulate the attributes but I can't figure out
> the selector. I haven't had any luck with "prev ~ siblings" or "prev +
> next". Thanks in advance.

Reply via email to