求一个参数传递JS写法
<select name= "c " class= "bd ">
<option value= "ms "> 墨水 </option>
<option value= "dsj "> 订书机 </option>
<option value= "pj "> > 票夹 </option>
</select>
<input name= "z " type= "hidden " id= "z " value= " ">
给段JS代码,让我在选择墨水时把墨水二个字写入隐藏框z内
选择订书机,把订书机三个写入
选择票夹把票夹二个字写入
------解决方案--------------------function aa()
{
document.getElementById( "z ").value=document.getElementById( "c ").value;
}
<select name= "c " class= "bd ">
<option value= "墨水 "> 墨水 </option>
<option value= "订书机 "> 订书机 </option>
<option value= "票夹 "> > 票夹 </option>
</select>
在onchange事件调函数就行
------解决方案--------------------有点晕
function aa()
{
var str=document.getElementById( "c ").value;
var str1= " ";
if(str== "ms ")
str1= "墨水 ";
if(str== "dsj ")
str1= "订书机 ";
if(str== "pj ")
str1= "票夹 ";
document.getElementById( "z ").value=str1;
}
------解决方案--------------------这样不是可以把文字传过去啦
------解决方案--------------------var obj = document.getElementById( "c ");
var strsel = obj.options[obj.selectedIndex].text;