Forum Moderators: open

Message Too Old, No Replies

how to update a select menu from a radio button

         

jamie

4:06 pm on Mar 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

i am having great difficutly changing the value of a select menu by clicking on a radio button. so far i have the following:

function changetext(type)
{
document.form1.description.options[document.form1.description.selectedIndex].value = type;
}
</script>

<form name="form1">
<input type="radio" name"radio" value="A" onClick="changetext('A')">A
<input type="radio" name"radio" value="B" onClick="changetext('B')">B

<select name="description" id="description">
<option value="A">Type A</option>
<option value="B">Type B</option>
</select>
</form>

i would like A or B to be selected when i click on the appropriate radio button.

this can't be hard, but i have tried so many different ways of selectedIndex, value, text, index, whatever- totally confused ;)

much appreciate any help

jamie

6:29 am on Mar 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



finally found the answer to this - i must have surfed 100 jscript pages!

document.form.select.selectedIndex = # (where # is a number, the key of the options array)