<table>
<tr>
<td><input type='checkbox'><span>Text1</span><input type='text'></td>
</tr>
<tr>
<td><input type='checkbox'><span>Text2</span></td>
</tr>
<tr>
<td><input type='checkbox'><span>Text3</span></td>
</tr>
<tr>
<td><input type='radio'><span>None of all</span></td>
</tr>
</table>
Below is my jQuery code..
$(':checkbox').live('change',function()
{
$(':radio').prop('checked',!$(this).prop('checked'));
});
$(':radio').live('change',function()
{
$(':checkbox').prop('checked',!$(this).prop('checked'));
});
$('table :text').live('keyup', function() {
var um = $(this).closest('td').find('input');
if ($(this).val().length > 0) {
um.prop('checked', true);
}
else {
um.prop('checked', false);
}
});
What the above code will do is
1. Checkboxes and Radio button are mutually exclusive
2. On change of a textbox automatically the checkbox inside its parent will checked/unchecked.
But
My concern is When i first click radio button, Then if i change text in textbox the checkbox will be checked but the radio button remains unchecked.. Why this is happening.. Please help me on this..
Had the same Problem with an autocomplete Plugin where a selection of that changed the text element but did not trigger the change event. You could add a
after your if/else