选择下拉框给多个文本框赋值 select

 也许从标题上很难理解,我这里解释下:

一个下拉框,下面有姓名、电话、地址等文本框要填的内容:

选项1

选项2

选项3

选择下拉框 选项一,下面文本框里要对应填上姓名、电话、地址等信息

 

了解我要表达的想法了吗?

 

Javascript代码
  1. <script type="text/javascript">   
  2. function filltext(str) {  
  3.     var strs= new Array();  
  4.     strs= str.split(",")  
  5. document.getElementById('name').value=strs[0]  
  6. document.getElementById('tel').value=strs[1]  
  7. document.getElementById('address').value=strs[2]  
  8. }  
  9.    </script>  

select 标签加上 onChange="filltext(this.options[this.selectedIndex].value)" 这个动作,去执行脚本

最后,在option里的value赋值,类似 value=“张三,13535353535,北京市朝阳区湾子街217号”

未经允许不得转载:Windy's Blog » 选择下拉框给多个文本框赋值 select

赞 (1)