开发者

Selecting a radio button when a dropdown value changes

My setup is something like this:

radiobutton1 - selection1
radiobutton2 开发者_JAVA技巧- 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/>


without resorting to "use jQuery" here's what you can do to your select tags.

    <select id="selection1" onchange="document.getElementById('radiobutton1').checked = true;">

do the same for the other one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜