Forum Moderators: open
<form name=form>
<input type=hidden name=text>
<br>
<select>
<option value="31" onblur="document.form.text.value='1'">1</option>
<option value="28" onblur="document.form.text.value='2'">2</option>
<option value="30" onblur="document.form.text.value='3'">3</option>
<option value="31" onblur="document.form.text.value='4'">4</option>
<option value="30" onblur="document.form.text.value='5'">5</option>
</select>
</form>
<form name=form>
<input type=text name=text>
<br>
<select name=select onChange="document.form.text.value=document.form.select.option.id">
<option id="1" value="30">1</option>
<option id="2" value="28">2</option>
<option id="3" value="40">3</option>
<option id="4" value="60">5</option>
<option id="5" value="454">6</option>
</select>
</form>
it still doesn't work, but maybe it is closer?
What you could do is this:
Have numbers as values in the options, and translate them using arrays to what the functions need.
For example:
<script type="text/javascript">
var arrayOne = new Array()
arrayOne[1]="One"
arrayOne[2]="Two"
arrayOne[3]="Three"
arrayOne[4]="Four"
arrayOne[5]="Five"
var arrayTwo = new Array()
arrayTwo[1]="some location"
arrayTwo[2]="some other location"
arrayTwo[3]="some url"
arrayTwo[4]="some uri"
arrayTwo[5]="some address"
function someFunction() {
alert(arrayTwo[document.frm.sel.value])
}
</script>
<form name="frm" onsubmit="someFunction(); return false;">
<input type="text" name="text">
<br>
<select name="sel" onchange="document.frm.text.value=arrayOne[this.value];">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="submit" value="Submit">
</form>
example has value set to the number of days in each month, so the only values are 29, 30, and 31
[webmasterworld.com...]