i have html form looks this:
<td><input type='checkbox' id='a[] '><input type='text' id='b[]'></td> <td><input type='checkbox' id='a[] '><input type='text' id='b[]'></td>
within jquery function enable / disable associated input text input - b when checkbox clicked.
i unsure how can reference each field individually within jquery .click() function when using array.
any appreciated!
similar concept thomas, executes on page load , throws in .focus() measure:
$(function(){ var togglestate = function(){ if($(this).is(':checked')) $(this).next('[name="b"]').removeattr('disabled').focus(); else $(this).next('[name="b"]').attr('disabled','disabled'); }; //bind event , fire off on page load $('input[name="a"]').bind('click',togglestate).each(togglestate); })
also, shouldn't have duplicate ids... use name attribute or target classes.
<table> <tr><td><input type='checkbox' name='a'><input type='text' name='b'></td></tr> <tr><td><input type='checkbox' name='a'><input type='text' name='b'></td></tr> </table>
Comments
Post a Comment