...

View Full Version : select onchange -> populate textbox



webosb
07-16-2007, 04:36 PM
i'm having trouble with populating a textbox in a seperate form on the same page when the select option is changed:

the following onchange doesnt work.... can someone tell me how to fix this:

<div id="dropdown1">
<form action="" class="niceform">
<select size="1" id="mySelect1" name="mySelect1" class="width_130" onchange="document.searchbox.searchquery.value=this.selectedIndex">
<option selected="selected" value="Blah">Blah</option>
<option value="Test">Test</option>
<option value="Test2">Test 2</option>
<option value="Test3">Test 3</option>
</select>
</form>
</div>
<div id="dropdown2">
<form action="" class="niceform">
<select size="1" id="mySelect2" name="mySelect2" class="width_170" onchange="document.searchbox.searchquery.value=this.selectedIndex">
<option selected="selected" value="Blah2">Blah2</option>
<option value="Test">Test</option>
<option value="Test 2">Test 2</option>
<option value="Test 3">Test 3</option>
</select>
</form>
</div>
<div id="searchbox">
<form action="" name="searchbox">
<input name="searchquery" id="searchquery" value="Search" onfocus="if (this.value == 'Search') this.value = '';" type="text" class="form" />
<input name="" type="submit" class="search" value="" />
</form>

jryoung
07-16-2007, 08:15 PM
Instead of this.selectedIndex try:
this.options[this.selectedIndex].value

webosb
07-16-2007, 08:23 PM
not working... 3 forms may be causing an issue?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum