请问通过javascript怎么获得下拉列表的值,显示在文本框中啊(急等)

guoming1 2005-08-01 02:13:56
请知道的朋友赐教!!!
...全文
357 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgzymzx 2005-08-01
  • 打赏
  • 举报
回复
//-------------------------------------------------------
//功 能:将指定列表选中的项的文本显示到指定的text框中
//-------------------------------------------------------
function SeltxtToText(paSel,paTxt){
var selObj, txtObj,i;
selObj = eval(paSel);
txtObj = eval(paTxt);
i = selObj.selectedIndex;
if(selObj.item(i).text == '选择'){
txtObj.value = ""
} else {
txtObj.value = selObj.item(i).text;
}
}
公共函数:第一个参数是制定的下拉选择框,第二个参数为指定的文本框。
格式为:document.frmname.objname
goodstuday 2005-08-01
  • 打赏
  • 举报
回复
<select name="select" onChange="test.value=this.value;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="text" name="test">
安迪 2005-08-01
  • 打赏
  • 举报
回复
更新一下:
<script type="text/javascript">
<!--
function func() {
var n = document.F1.S1.selectedIndex;
document.F1.T1.value=document.F1.S1.options[n].text;
}
// -->
</script>
<form name="F1" action="#">
<select name="S1">
<option>AAAA
<option>BBBB
<option>CCCC
</select>
<input type="button" value="OK" onclick="func()">
<input type="text" name="T1" value="">
</form>
安迪 2005-08-01
  • 打赏
  • 举报
回复
<script type="text/javascript">
<!--
function func() {
var n = document.F1.S1.selectedIndex;
alert(document.F1.S1.options[n].text);
}
// -->
</script>
<form name="F1" action="#">
<select name="S1">
<option>AAAA
<option>BBBB
<option>CCCC
</select>
<input type="button" value="OK" onclick="func()">
</form>
yulduan 2005-08-01
  • 打赏
  • 举报
回复
var select_id = document.getElementById("selectName").value;
就可以了,你试试
selectName为select的name.

87,914

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧