views:

39

answers:

1

hi all, i have text boxes in HTML Like -

<table id="tbl">
<tr>
    <td><input type="text" name="t1[]"></td>
    <td><input type="text" name="t2[]"></td>
    <td><input type="text" name="t3[]"></td>
</tr>
<tr>
    <td><input type="text" name="t1[]"></td>
    <td><input type="text" name="t2[]"></td>
            <td><input type="text" name="t3[]"></td>
</tr> 
</table>

Now I want to fill the TextBoxes in first row with some value on onchange event of another textbox. How should i do it? the following answer by Rahul Fills all the textboxes with the same value but i want to only first 2 tds of first tr of given table with different values

Please Help. Thanks In Advance!

A: 

It would be better to use a js library like jQuery. In jQuery you can do like this.

$(function(){
    $("yourtextboxselector").change(function(){
        $("#tbl1 tr:first input:text").each ( function(){
            $(this).val('new value');
        });
    });
});

<table id="tbl1">
<tr>
    <td><input type="text" name="t1[]" /></td>
    <td><input type="text" name="t2[]" /></td>
</tr>
<tr>
    <td><input type="text" name="t1[]" /></td>
    <td><input type="text" name="t2[]" /></td>
</tr>
<tr>
    <td><input type="text" name="t1[]" /></td>
    <td><input type="text" name="t2[]" /></td>
</tr>
</table>
rahul
Thanks dude for quick reply!Can we do it in Mootools way?
Sorry, I am not familiar with mootools.
rahul

related questions