Selecting a radio button when a dropdown value changes

Posted by Tim F. on Stack Overflow See other posts from Stack Overflow or by Tim F.
Published on 2010-03-23T13:52:48Z Indexed on 2010/03/23 14:03 UTC
Read the original article Hit count: 305

Filed under:
|
|
|
|

My setup is something like this:

radiobutton1 - selection1
radiobutton2 - selection2 textinput1

I want radiobutton1 to be selected whenever selection1 is changed, and I want radiobutton2 to be selected whenever either selection2 or textinput1 is changed.

There has to be a simple javascript solution here... I just can't find it.

Here's my actual code ("$semopt" is a string holding the html code for the options on the first selection input):

<input type='radio' name='semester' value='existing'/>Existing semester: 
    <select name='sem_id'">$semopt
    </select><br/>
<input type='radio' name='semester' value='new'/>New Semester: 
    <select name='sem_name'">
        <option value='Fall'>Fall</option>
        <option value='Spring'>Spring</option>
    </select> 
    <input name='sem_year' value='$thisyear' size='5'"/><br/>

© Stack Overflow or respective owner

Related posts about radiobutton

Related posts about select