你的rs包含了postCode ,只是将他取出显示的问题,
加个〈input type='hidden' ...〉取值,
option上加onchange事件 innerHTML放入你要显示的位置,

解决方案 »

  1.   


    用js实现,给你写好了<%@ page language="java" pageEncoding="GB18030"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html:html lang="true">
      <head>
        <html:base />
        
        <title>1.jsp</title> <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <script type="text/javascript">
    function test()
    {
    var v  = document.getElementById("test").value;
    document.getElementById("test2").value=v;
    }


    </script>
      </head>
      
      <body>
    <select name="area" id="test" onchange="test()">
    <% while (rs.next())
    {
    %>
    <option value=<%=rs.getString("postcode")%>> <%=rs.getString("areaName")%> </option>
    <%
    }
    %> 
    </select>
       <input id="test2" type="text" value="">
      </body>
    </html:html>
      

  2.   

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>test</title>
    <script type="text/javascript" defer="defer">
    var city = document.all("city");
    var code = document.all("code");
    code.value = city.options[city.selectedIndex].value;
    function tranCity(){
    code.value = city.options[city.selectedIndex].value;
    }
    </script>
    </head>
    <body>
    <select id="city" onchange="tranCity()">
    <option value="010001">北京</option>
    <option value="020001">天津</option>
    <option value="030001">上海</option>
    </select>
    <br>
    <input type="text" id="code" value=""/>
    </body>
    </html>
      

  3.   

    下拉列表框应该是这样的
    <option value="010001">北京</option>
    <option value="020001">天津</option>
    <option value="030001">上海</option>