从下拉菜单选择后把对应的多个值分别填充到多个文本框中 这个用js好实现。代码我是用,发消息给我,留下你的E-mail,明天发给你。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 晕 这还说的不清楚啊? 例: 下拉菜单中选项有 A B C三个当选A时 自动把数组中的内容如 1 2 3 分别填入三个文本框中当选B时 自动把数组中的内容如 4 5 6 分别填入三个文本框中当选C时 自动把数组中的内容如 7 8 9 分别填入三个文本框中 <select id="sel" onchange="setVal()"><option value='1,2,3'>A</option><option value='4,5,6'>B</option><option value='7,8,9'>C</option></select><input type='text' id='a'/><input type='text' id='b'/><input type='text' id='c'/><script language="javascript">function setVal(){ var _selObj = document.getElementById("sel"); var _selVal=_selObj.options[_selObj.selectedIndex].value; var _splitVal = _selVal.split(","); try{ document.getElementById("a").value=_splitVal[0]; document.getElementById("b").value=_splitVal[1]; document.getElementById("c").value=_splitVal[2]; }catch(e){ alert("Error in Page!"); }}</script> 学生<select id="student" onchange="setVal(this)"><option value='' xuehao="" xinbie=""></option><option value='1' xuehao="001" xinbie="男">张三</option><option value='1' xuehao="002" xinbie="男">李四</option><option value='1' xuehao="003" xinbie="女">王五</option></select><br>学号<input type='text' name="xuehao" readonly><br>性别<input type='text' name="xinbie" readonly><br><script language="javascript">function setVal(obj){ var selectedOption=obj.options[obj.selectedIndex]; document.getElementById("xuehao").value=selectedOption.xuehao; document.getElementById("xinbie").value=selectedOption.xinbie;}</script> 如果select数据是从数据库中读取过来的,改怎么写代码?请楼上的给指导指导。====天堂世家====MSN:[email protected]QQ:85850256 moodboy1982(虎落平川被犬欺): 不能拿出来共享一下吗? 在线等,,请教js开发的安卓应用,关于安卓上下左右键盘控制 [急],如何获得可编辑Div光标位置? 菜鸟提问:请问怎么实现图片下拉效果 谈一谈我对系统架构的理解,欢迎大家一起讨论 文本框背景色慢慢淡出 急。 一个JS正则表达式的问题! 建立个div+css群 使用alert问题?急,在线等待 如何判断userid只有english require.js如何实现循环依赖的? 实现90 °旋转,急! javascript控制页面显示的问题!
例: 下拉菜单中选项有 A B C三个当选A时 自动把数组中的内容如 1 2 3 分别填入三个文本框中
当选B时 自动把数组中的内容如 4 5 6 分别填入三个文本框中
当选C时 自动把数组中的内容如 7 8 9 分别填入三个文本框中
<option value='1,2,3'>A</option>
<option value='4,5,6'>B</option>
<option value='7,8,9'>C</option>
</select>
<input type='text' id='a'/>
<input type='text' id='b'/>
<input type='text' id='c'/>
<script language="javascript">
function setVal(){
var _selObj = document.getElementById("sel");
var _selVal=_selObj.options[_selObj.selectedIndex].value;
var _splitVal = _selVal.split(",");
try{
document.getElementById("a").value=_splitVal[0];
document.getElementById("b").value=_splitVal[1];
document.getElementById("c").value=_splitVal[2];
}catch(e){
alert("Error in Page!");
}
}
</script>
<option value='' xuehao="" xinbie=""></option>
<option value='1' xuehao="001" xinbie="男">张三</option>
<option value='1' xuehao="002" xinbie="男">李四</option>
<option value='1' xuehao="003" xinbie="女">王五</option>
</select><br>
学号<input type='text' name="xuehao" readonly><br>
性别<input type='text' name="xinbie" readonly><br><script language="javascript">
function setVal(obj){
var selectedOption=obj.options[obj.selectedIndex];
document.getElementById("xuehao").value=selectedOption.xuehao;
document.getElementById("xinbie").value=selectedOption.xinbie;}
</script>
MSN:[email protected]
QQ:85850256