注册 登录
编程论坛 J2EE论坛

【小问题求解】

刘杰明 发布于 2011-09-14 17:19, 378 次点击
<table  align="center"width="392" height="230" border="0" cellpadding="0" cellspacing="0">
<form name="myform">
  <tr>
    <td bgcolor="#FF9999"><div align="center"><span class="STYLE2">送货地址确认</span></div></td>
  </tr>
  <tr>
    <td bgcolor="#FF9999" class="STYLE2"><div align="center">省份:
          <select name="select"id="select">
            <option>北京市</option>
            <option>山东省</option>
            <option>河北省</option>
          </select>
    </div></td>
  </tr>
  <tr>
    <td bgcolor="#FF9999" class="STYLE2"><div align="center">城市:
        <select name="select2" id="select2"size="1">
          <option>北京市</option>
          <option>济南市</option>
          <option>石家庄市</option>
        </select>
    </div></td>
  </tr>
  <tr>
    <td bgcolor="#FF9999" class="STYLE2"><div align="center">区:
        <select name="select3" id="select3"size="1">
          <option>西城区</option>
          <option>高新区</option>
          <option>历城区</option>
        </select>
    </div></td>
  </tr>
  </form>
</table>
写这么多其实很简单,就是想问一下怎样取出列表项中的值,这是弹出的一个页面,我想将列表子项值提取出来显示在主页面的文本框中,来点代码吧,好理解
3 回复
#2
xmlz2011-09-15 10:33
你这个是取不到值的,改option改一下
   <select name="select"id="select">
            <option value="北京市">北京市</option>
            <option value="山东省">山东省</option>
            <option value="河北省">河北省</option>
</select>
#3
baojin2011-09-22 15:06
index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'index.jsp' starting page</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">
    -->

  </head>
 
  <body>
    <%
        request.setCharacterEncoding("gbk");
        String s1 = request.getParameter("select1");
        String s2 = request.getParameter("select2");
        String s3 = request.getParameter("select3");
        out.println(s1+","+s2+","+s3);
     %>
  </body>
</html>



test.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'test.jsp' starting page</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">
    -->

  </head>
 
  <body>
  <form action="./index.jsp" method="post">
   <table  align="center"width="392" height="230" border="0" cellpadding="0" cellspacing="0">
   
      <tr>
    <td bgcolor="#FF9999"><div align="center"><span class="STYLE2">送货地址确认</span></div></td>
      </tr>
      <tr>
        <td bgcolor="#FF9999" class="STYLE2"><div align="center">省份:
          <select name="select1" id="select">
            <option>北京市</option>
            <option>山东省</option>
            <option>河北省</option>
          </select>
        </div></td>
      </tr>
      <tr>
    <td bgcolor="#FF9999" class="STYLE2"><div align="center">城市:
        <select name="select2" id="select2"size="1">
          <option>北京市</option>
          <option>济南市</option>
          <option>石家庄市</option>
        </select>
    </div></td>
  </tr>
  <tr>
    <td bgcolor="#FF9999" class="STYLE2"><div align="center">区:
        <select name="select3" id="select3"size="1">
          <option>西城区</option>
          <option>高新区</option>
          <option>历城区</option>
        </select>
    </div></td>
  </tr>
 

</table>
 <div align="center"><input type="submit" value="确认"/></div>
  </form>
  </body>
</html>

效果展示:
test.jsp
只有本站会员才能查看附件,请 登录


index.jsp
只有本站会员才能查看附件,请 登录


界面我就没做了,我就按群主的意思显示在主页上,美观上不用纠结。。。
#4
baojin2011-09-22 15:08
只有本站会员才能查看附件,请 登录
这是test界面。。上面那个是index界面
1