gerkintrigg Posted January 10, 2008 Share Posted January 10, 2008 Hello. i have a drop-down box that i want to be able to change the checked value of a radio button - in other words de-select the one that is selected, and re-select the one that's not. Is there a simple way of doing this? I've tried onChange="permissions.value='public'" and onChange="permissions.checked=false" but neither work. I'm sure I'm doing something stupid, but I can't put my finger on it. please help! Thanks. Trigg, Link to comment https://forums.phpfreaks.com/topic/85351-changing-a-radio-button-dynamically/ Share on other sites More sharing options...
jos. Posted January 10, 2008 Share Posted January 10, 2008 make sure you are accessing the node properly through the parent node. ie... function changeEm(Your_form_name){ var Your_form = document.getElementById('Your_from_name'); //parent node var radioButton1 = Your_form.radio_button_name.checked; //first child node var radioButton2 = Your_form.radio_button_name.checked; //second child node if(radioButton1 == false){/*change the other one here*/} //conditions elseif(radioButton2 == false){/*Change the other one here*/} } <input type="radio" id="your_radio_button" onChange="changeEm(this.parentNode.id)" /> Hope that helped. Jos. Link to comment https://forums.phpfreaks.com/topic/85351-changing-a-radio-button-dynamically/#findComment-435516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.