<select name="nameSelect" id="nameSelect" onChange="document.getElementById('eName').value = this.options[this.selectedIndex].getAttribute('eName')">
<option value='' eName=''>请选择</option>
<option value='我' eName='i'>我</option>
<option value='你' eName='you'>你</option>
<option value='他' eName='he'>他</option>
<select>
<input name="eName" id="eName" value=''>

解决方案 »

  1.   

    我的数据库有很多条数据,不能用js写在代码里,要与数据表class 相连取得中文名name 和英文名Ename我现在只取得一个name, 还需要一个Ename 在下一个下啦框里关联的源程序,谢谢
      

  2.   

    用这个怎么改不出来呢?
    怎样吧这段程序改成3级联动的啊??<script language = "JavaScript">var onecount;
    onecount=0;
    var subcat = new Array(); <%
     int count = 0;
    ResultSet rs = stat.executeQuery("select * from tab_zone order by ZoneID");//读取数据
    while(rs.next())
    {
    String sname=rs.getString("ZoneName");//转换字符类型
    %>
    subcat[<%=count%>] = new Array("<%=sname%>","<%=rs.getInt("FZoneID")%>","<%=rs.getInt("ZoneID")%>");//产生数组
    <%
            count = count + 1;
    }
    %>
    onecount=<%=count%>;
     
    function changelocation(id)
        {
        document.form1.smallsortselect.length = 0; 
     
        var id=id;
        var i;
        document.form1.smallsortselect.options[0] = new Option('选择二级分类','');
        for (i=0;i < onecount; i++)
            {
                if (subcat[i][1] == id)
                { 
                    document.form1.smallsortselect.options[document.form1.smallsortselect.length] = new Option(subcat[i][0], subcat[i][2]);
                }        
            }
            
        }      
     
    </script>
    </head>
    <form name="form1" method="post" action="">
    <table width="500"  border="0" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td width="180" height="20" align="right">选择一级分类:</td>
        <td width="320">
      <select name="bigsortselect" onChange="changelocation(document.form1.bigsortselect.options[document.form1.bigsortselect.selectedIndex].value)" size="1">
        <option value="2">请选择一级分类</option>
    <%
    ResultSet rs1 = stat.executeQuery("select * from tab_zone where FZoneID = 1 order by ZoneID");
    String Bname="";while(rs1.next()){
    Bname = rs1.getString("ZoneName");
    %>
       <option value="<%=rs1.getInt("ZoneID")%>"><%=Bname%></option>
    <%
    }%>
         </select><br/>
        </td>
      </tr>
      <br/>
      <tr>
        <td height="20" align="right">选择二级分类:</td>
        <td>
      <select name="smallsortselect">
        <option value="" selected>请选择二级分类</option>
     
         </select> 
     
     </td>
      </tr>
      <tr>
        <td height="20" colspan="2" align="center"><input type="submit" name="Submit" value="提交"></td>
      </tr></table>
    </form>
      

  3.   

    用HTML标签和JS来实现是最简单的。
      

  4.   

    好像没有人会阿!这次我的问题好像比较麻烦,连CSDN都解决不了!
      

  5.   

    你说的是这个么?我知道js可以,但是数据多了怎么办?有200-300条数据要经常更新,怎么弄,不会让我每次都要改源代码吧!
    <select name="nameSelect" id="nameSelect" onChange="document.getElementById('eName').value = this.options[this.selectedIndex].getAttribute('eName')">
    <option value='' eName=''>请选择</option>
    <option value='我' eName='i'>我</option>
    <option value='你' eName='you'>你</option>
    <option value='他' eName='he'>他</option>
    <select>
    <input name="eName" id="eName" value=''>
      

  6.   

    你可以把你的关联字段存在HashMap中,Map就是解决这个用的。