lundi 20 juillet 2015

Checkboxes control Radio Checked/Unchecked

I have a checkout page with two radio buttons one for 'Register Account' and 'Guest Account' checkout methods.

I want a single checkbox that when it is checked, it checks the Register Account radio button and when it isn't checked it checks the Guest Account checkout radio button.

Here is my code so far: http://ift.tt/1MDyizU

HTML:

Remember Me for Future Purposes :<input type="checkbox" id="checkbox1"/> <br/><br/>

Register Account :<input type="radio" id="radio1" name="radio"/><br>
Guest Checkout :<input type="radio" id="radio2" name="radio"/><br>

JS:

jQuery('#checkbox1').click(function(){
    jQuery('#radio1').attr('checked', true);    
});        

jQuery('#checkbox1').click(function(){       
    jQuery('#radio2').attr('checked', false);  
});  

I got part of the functionality down but I don't know how to uncheck a radio button when a checkbox is unchecked.




Aucun commentaire:

Enregistrer un commentaire