![]() |
|
|
+ Search |
![]()
|
Apr 6th, 2008 19:27
ha mo, Ole Clausen, thulasi ram,
Getting the text and value from two text inputs, you can add a new
option at the end of a dropdown like this:
<script type="text/JavaScript">
function myTrans(f) {
f.mySel.options[f.mySel.length] = new Option();
f.mySel.options[f.mySel.length-1].text = f.txt.value;
f.mySel.options[f.mySel.length-1].value = f.val.value;
}
</script>
<form>
<select name="mySel">
<option value="0">first</option>
<option value="1">second</option>
<option value="2">third</option>
</select>
<input type="text" name="txt">
<input type="text" name="val">
<button onclick="myTrans(this.form)">transfer</button>
</form>
===========================================================
You can even make the function a little 'sexier' like this:
function myTrans(f) {
f.mySel.options[f.mySel.length] = new Option(f.txt.value,
f.val.value);
}
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com