html 选中select 值传入文本框(显示值 和value)传入两个文本框 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script type="text/javascript"> function showSelect(obj) { document.getElementById('val').value = obj[obj.selectedIndex].value; document.getElementById('txt').value = obj[obj.selectedIndex].text; } </script><div> <select onchange="showSelect(this)"> <option value="1">一</option> <option value="2">二</option> <option value="3">三</option> </select> 显示<input id='txt' value='' type="text" /> 值<input id='val' value='' type="text" /> </div> 1楼应该是document.getElementById('val').value = obj.options[obj.selectedIndex].value; +可以稍作修改 function showSelect(obj) { document.getElementById('val').value = obj.value;//直接value document.getElementById('txt').value = obj[obj.selectedIndex].text; } document.getElementById('val').value = obj[obj.selectedIndex].value; 过滤器的使用 关于在jsp中如何用jquery循环拼接xml jqueryUI 的tabs可否在执行翻页时有loading效果 急......如何在光标闪烁位置插入html控件?? popup窗口奇怪问题 javascript有没有象vs.net那样快速开发功能强大的开发环境或工具 请教,这样的 htm 怎么取得 body 里的html? 怎样使子窗口获得焦点? 自动输入用户名 两行滚动,鼠标放上去不能停止滚动的问题 js number类型转换怪异问题 select 赋值、取值问题。
<script type="text/javascript"> function showSelect(obj) {
document.getElementById('val').value = obj[obj.selectedIndex].value;
document.getElementById('txt').value = obj[obj.selectedIndex].text;
}
</script>
<div>
<select onchange="showSelect(this)">
<option value="1">一</option>
<option value="2">二</option>
<option value="3">三</option>
</select>
显示<input id='txt' value='' type="text" />
值<input id='val' value='' type="text" />
</div>
可以稍作修改
function showSelect(obj) {
document.getElementById('val').value = obj.value;//直接value
document.getElementById('txt').value = obj[obj.selectedIndex].text;
}