Jump to content

Changing a radio button dynamically


gerkintrigg

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.