jquery -- how to set one radio button based on another getting clicked -


let's have form includes this:

<input type='radio' name='o37_field1' value='aaa'>aaa <input type='radio' name='o37_field1' value='bbb'>bbb  <input type='radio' name='o44_field1' value='aaa'>abcdef <input type='radio' name='o44_field1' value='bbb'>baksdf  <input type='radio' name='o58_field1' value='aaa'>wisdof <input type='radio' name='o58_field1' value='bbb'>safhwr 

here's need jquery having trouble:

if "aaa" clicked on in 1 of sets, set/check "aaa" other ones, , same other radio buttons have "field1" part of name , "aaa" value.

ditto bbb

any ideas?

this set radios value of "aaa" when 1 checked:

$(document).ready(function() {    $(':radio[value=aaa]').change(function(){        $(':radio[value=aaa]').prop('checked',true);    }); }); 

the more robust solution selecting "like" values when 1 clicked:

$(document).ready(function() {     $(':radio').change(function(){               $(':radio[name$='field1'][value='+$(this).val()+']').prop('checked',true);    }); }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -