Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  124] [ 4]  / answers: 1 / hits: 33421  / 15 Years ago, tue, march 31, 2009, 12:00:00

I was wondering if anyone knew of a way to access a hidden field (by client id) within a table row using jquery.



$(#tblOne).find(tr).click(function() {
var worker = $(this).find(:input).val();
});


I find that the above works for a row that has only one input, but I need some help figuring out a way to get the value by the inputs name.



Here's the example of a table row. How would I access the two fields by their id's?



<table id=tblOne>
<tr>
<td>
<asp:HiddenField id=hdnfld_Id Text='<% Eval(ID) %>'></asp:HiddenField>
</td>
<td>
<asp:HiddenField id=hdnfld_Id2 Text='<% Eval(ID2) %>'></asp:HiddenField>
</td>
</tr>
</table>

More From » jquery

 Answers
76

With the way you have it setup right now, you could do this:



$('tr td', '#tblOne').eq(0).find(':input').val(); // find input in 1st TD
$('tr td', '#tblOne').eq(1).find(':input').val(); // find input in 2nd TD


Using this you don't have to worry about the input's ClientID.


[#99775] Tuesday, March 24, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
3 Years ago
alorac questions
Sat, Oct 10, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
;