select javascript test
时间:2010-09-04 来源:icedog
<html>
<head>
<script type="text/javascript">
function change(list)
{
var array;
var idx;
for (var i = 0; i < list.length; i++)
{
if (list.options[i].selected)
{
//add to array here sorry cant remember how
idx = i;
}
}
var value = list.options[idx].value;//list.length - array.length;
Form1.textbox.value = value.toString();
}
</script>
</head>
<body>
<form id="Form1" name="Form1">
<select name="listbox" size="6" onchange ="change(this.form.listbox)">
<option value="blah">1</option>
<option value="blah2">2</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
<option value="blah3">3</option>
</select>
<INPUT TYPE="text" NAME="textbox" VALUE="">
</form>
</body>
</html>