Rat
Not bored. Never bored.,
My brain appears to have stopped working, so I wonder if anyone can help with a simple bit of javascript.
I have a list of items, some of which are exclusive and some of which are not, and so some have radio buttons and some have checkboxes. Basically, I want some options to be visible or otherwise (by changing 'display' to either none or block) depending on the state of the checkboxes. The onchange handler seemed to be my best option, but it's not working like I expected. Essentially, if a radio button or check box is selected, a particular related block of text should be visible; if it is deselected, the text should vanish.
At the moment, for example, using radio buttons, if I select radio1, the text (initially display: none) appears as expected. If I then select radio 2, it doesn't disappear. If I select radio1 again, it disappears again. This is obviously not what I want. If I use onclick instead, the text appears and disappears each time I click the same radio button, which makes even less sense. The visibility (or rather display) of the text needs to depend on the on/off state of the radio or checkbox.
Am I missing something really obvious? Is there a different event handler I can use or is this going to need more complex scripting? Because it's been a while since I was competent in anything more than basic scripting.
I have a list of items, some of which are exclusive and some of which are not, and so some have radio buttons and some have checkboxes. Basically, I want some options to be visible or otherwise (by changing 'display' to either none or block) depending on the state of the checkboxes. The onchange handler seemed to be my best option, but it's not working like I expected. Essentially, if a radio button or check box is selected, a particular related block of text should be visible; if it is deselected, the text should vanish.
At the moment, for example, using radio buttons, if I select radio1, the text (initially display: none) appears as expected. If I then select radio 2, it doesn't disappear. If I select radio1 again, it disappears again. This is obviously not what I want. If I use onclick instead, the text appears and disappears each time I click the same radio button, which makes even less sense. The visibility (or rather display) of the text needs to depend on the on/off state of the radio or checkbox.
Am I missing something really obvious? Is there a different event handler I can use or is this going to need more complex scripting? Because it's been a while since I was competent in anything more than basic scripting.