...

View Full Version : Changing values in forms with dropmenu onChange



gurela
05-31-2009, 03:11 PM
I need some help with my drop menu updating the name of a textarea onchange. I have simplified the code i have so far to what i thought would work but im stuck. Any help would be greatly appreciated.


<!--THIS CHANGES THE VALUE OF THE TEXT AREA WITH onChange-->

<form id="dropmenu">
<select name="selectitem" onChange="textbox.itemID_update.value=dropmenu.selectitem.value">
<option value="id=1">ID One</option>
<option value="id=2">ID two</option>
<option value="id=3">ID three</option>
<option value="id=4">ID four</option>
<option value="id=5">ID five</option>
<option value="id=6">ID six</option>
</select>
</form>

<form id="textbox">
<input name="itemID_update" type="text" value="">
</form>




<!--THIS IS WHAT IM ATEMPTING DO DO. I WOULD LIKE THE onChange TO SET THE NAME INSTEAD OF THE VALUE OF THE TEXT AREA-->

<form id="dropmenu">
<select name="selectitem" onChange="textbox.itemID_update.name=dropmenu.selectitem.value">
<option value="id=1">ID One</option>
<option value="id=2">ID two</option>
<option value="id=3">ID three</option>
<option value="id=4">ID four</option>
<option value="id=5">ID five</option>
<option value="id=6">ID six</option>
</select>
</form>

<form id="textbox">
<input name="itemID_update" type="text" value="1">
</form>

abduraooft
05-31-2009, 03:24 PM
Try

<select name="selectitem" onchange="document.getElementById('itemID_update').setAttribute('name',this.value);">
<option value="id=1">ID One</option>
<option value="id=2">ID two</option>
<option value="id=3">ID three</option>
<option value="id=4">ID four</option>
<option value="id=5">ID five</option>
<option value="id=6">ID six</option>
</select>
</form>

<form id="textbox" >
<input name="itemID_update" id="itemID_update" type="text" value="1"/>
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum