select
select的使用方法
1 <form name = "form1" action = "" method = "post"> 2 <input type = "text" value = "你过得好吗" name = "textfiled"/> 3 你喜欢的颜色是 <select name = "oa" onchange="Fcolor()"> 4 <option value = "red">红</option> 5 <option value = "white">白</option> 6 <option value = "black">黑</option> 7 <option value = "blue" selected="selected">蓝</option> 8 <option value = "green">绿</option> 9 <option value = "yellow">黄</option> 10 </select> 11 12 </form>
js文件中添加如下内容
1 function Fcolor(){ 2 var e = window.event; 3 var obj = e.srcElement; 4 form1.textfiled.style.color = obj.options[obj.selectedIndex].value; 5 }