PDA

View Full Version : asp select list



mini_minh
05-20-2007, 09:41 AM
hiya was just wondering...

if i had a select list like...

<select name="list">
<option name="option1" value="1">option 1</option>
<option name="option2" value="2">option 2</option>
<option name="option3" value="3">option 3</option>
</select>

and a textbox like...
<input type="text" name="text">

was wondering how to change the value of the text box depending on what the user selects in the select list...like if the user selects option 1 the value of the text box will change to 1.

thanx in advance.

DimX
05-20-2007, 11:28 AM
<select name="list" onchange="elements['text'].value = this.value">
<option name="option1" value="1">option 1</option>
<option name="option2" value="2">option 2</option>
<option name="option3" value="3">option 3</option>
</select>

<input type="text" name="text">

The elements['text'] part could also be replaced with document.getElementById or with an absolute path to the text input, but this one should be OK.

Twey
05-20-2007, 11:32 AM
onchange="this.form.elements['text'].value = this.value;"

mini_minh
05-20-2007, 11:40 AM
XD thanx heaps guys