How do I get the value clicked in each row (generated using AddRowTable plugin), i.e.,
<script type="text/javascript">
$("document").ready(function(){
$(".addRow-Max4").btnAddRow({maxRow:4, inputBoxAutoNumber:true});
$(".delRow").btnDelRow();
});
</script>
generates maximal 4 rows in a table and numbers each input box, so I get textfield1, textfield2 and so onin my table.
<table border="0" >
<tr>
<th colspan="2">Input your data</th>
<th><input type="button" value="Add Row" class="addRow-Max4"/></th>
</tr>
<tr><td>
<a href="#" class="autofill">Apple</a>
<a href="#" class="autofill">Banana</a>
<a href="#" class="autofill">Mango</a>
</td><td><input type="text" name="textfield" class="autofill" size="25"/></td>
<td><img src="./images/cross.gif" class="delRow" border="0"></td>
</tr>
</table>
Now I might decide for Apple in row1, Mango in row2 and so on and would like that the according textfield for this row is filled.
I have
$("a[class=autofill]").live("click", function(){
$("input[name=textfield1]").val($(this).text());
return false;
});
but how do I have to adjust it to make it dynamic for each row. Let’s say textfield1, textfield2, textfield3 and so on. As it is right now, I change the textfield1 each time a link is clicked. But I want to just change it if one of the corresponding (same row) link is clicked.
Did not get much of the insight for this issue. But here is my try to find all the input fields inside their parent TR.
This is what i tried:
http://jsfiddle.net/KU6Xw/