It doesn't makes sense to me since the second select element isn't a "select" element since you don't want the
option element be a child of
select element.
Anyway, this might help:
Code:
<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">
You can change the mode from 0 - 1. Comments explain the purpose.
Default is 0, which gets the options value.
Hope that helps.