日期:2014-05-16  浏览次数:20312 次

js select


我想用onchange 把右边select里的option.value动态的入到左边的input框里 替换里面的内容 请直接上代码 谢谢
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script>
function change(){
var selVal = document.getElementById('select').options[document.getElementById('select').selectedIndex].value;
document.getElementById('text').value = selVal;
}
</script>
</head>
<body>

分类ID:<input type="text" class="text" id="text" />  <select onchange="change();" id="select"><option value="美容护肤">美容护肤</option><option value="电击疗法">电击疗法</option><option value="按摩去皱">按摩去皱</option></select>
</body>
</html>