jquery Select the Select drop-down box to assign a value to the text box, the value of the first drop-down box cannot be assigned to the TextBox
Because select selects the first item by default ... When you select the first item, the onchange event is not fired. So you can't assign to a text box
Workaround.
Select drop-down box set the first item to make a useless placeholder option
<script type= "Text/javascript" > Function changeselect (obj) {var _this = obj; $ ("#goods_private_attr"). Val ($ (_this). Val ());
_this.options[0].selected = true; //The Select is initialized to the first one. so that the text box is modified and the same is selected again.
} </script>
<select id= "sel" style= "float:right; width:200px; z-index:1; position: absolute; left:110px; top:3px; height:22px; " onchange= "changeselect (this);" <option value= "" style= "Display:none" ></ Option> <option value= "111" >111</option> <option value= "222" > 222</option> <option value= "333" >333</OPTION></SELECT>
This overlaps with the text box and the above select. But the Z-index is higher.
<input type= "text" id= "goods_private_attr" name= "goods_private_attr" value= "" style= "position:absolute; width:175px; height:12px; left:111px; top:6px; Z-index:2; border:0; "/>
jquery Select to assign a value to the text box in the Select drop-down box