raman Posted April 22, 2009 Share Posted April 22, 2009 I have an HTML page on which I have one select box with select options -1.5, -1.4, -1.3 ,...0, 0.1, 0.2......1.4, 1.5 0.0 is the default selected value. I have a radio-button with 4 values, a b c d. a is the default selected radio button. I beed a javascript that would automatically change the value of select box to 0.1 if the user selects radio- button b, and change the value of select box to 0.2 if user selects button c, and change the value of select box to 1.0 if the user selects button d. Does someone have an idea ? Quote Link to comment Share on other sites More sharing options...
Darghon Posted April 22, 2009 Share Posted April 22, 2009 add an onclick event to your radio buttons create a function that will set the value of the selectbox and call that function with example code it would be //function setSelectValue(val){ document.getElementById('SelectBox').value = val; } //radio buttons <input type='radio' name='radiogroup' onclick='setSelectValue("0.0")' />a <input type='radio' name='radiogroup' onclick='setSelectValue("0.1")' />b <input type='radio' name='radiogroup' onclick='setSelectValue("0.2")' />c <input type='radio' name='radiogroup' onclick='setSelectValue("1.0")' />d //select box <select id='SelectBox'> <option value='-1.5'>-1.5</option> ... <option value='0.0' selected>0.0</option> ... </select> when you click on one of the radio buttons, the selected value of the selectbox will change accordingly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.