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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.