![]() | It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!) |
<option>
20200
</option>
<option>
12000
</option>
<option>
200
</option>

<script type="text/javascript">
/**
* Copy option's value/text to textbox
* Additional Feature: Be able to instruct the script as to the mode you wish.
* Created by Raymond Angana [username = rangana]
* First seen in devppl.com/forum
* This script must stay intact for legal use
*/
var ray=
{
transfer:function(inp,out,mod)
{
this.getID(inp).onchange=function()
{
ray.getID(out).value=mod?this.options[this.options.selectedIndex].text:this.value;
}
},
getID:function(el)
{
return document.getElementById(el); // Get the element's id
}
}
window.addEventListener?window.addEventListener('load',function()
{
/**
* @param1 - ID of the select element
* @param2 - ID of the textbox where you want the value be seen
* @param3 - Mode you wish the script to run. You could choose from 0/1
0 - Will use the value of the options
1 - Will use the text of the options
*/
ray.transfer('myselect','output',1); // Last argument could either be 0/1. If 0, then it will get the options value, if 1, it will get the options texts
},false):
window.attachEvent('onload',function()
{
/**
* @param1 - ID of the select element
* @param2 - ID of the textbox where you want the value be seen
* @param3 - Mode you wish the script to run. You could choose from 0/1
0 - Will use the value of the options
1 - Will use the text of the options
*/
ray.transfer('myselect','output',1); // Last argument could either be 0/1. If 0, then it will get the options value, if 1, it will get the options texts
}); // FF : IE
</script>
<select id="myselect">
<option value="Opt1">Option 1</option>
<option value="Opt2">Option 2</option>
<option value="Opt3">Option 3</option>
<option value="Opt4">Option 4</option>
<option value="Opt5">Option 5</option>
</select>
<input type="text" readonly="readonly" id="output">

Users browsing this forum: No registered users and 5 guests