作者bigtq13 (Tabitha~)
看板java
标题Re: [JSP ] 问一下关於传值的问题
时间Sun Jul 2 13:24:38 2006
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>注册帐号</title>
<meta http-equiv="Content-Type" content = "text/html;charset=UTF-8">
</head>
<script>
</script>
<body>
<form name="form" method="post" action="RegSucc.jsp">
*身分证字号:<input name="id_num" type="text" id="id_num" size ="10"><br>
*新密码:<input name="psw1" type="password" id="psw1" size ="15"><br>
*确认密码:<input name="psw2" type="password" id="psw2" size ="15"><br>
<table>
<tr>
<td>
*通讯地址:
</td>
<td>
<table id=row1>
<tr>
<td>
<select name = addrcounty onchange='getData(this)' >
<option value="1" default>台中</option>
<option value="2">台南</option>
</select>
</td>
</tr>
</table>
</td>
<td>
<table id=row2>
<tr id=row2>
<td>
<select name = addrcity>
<option value="万里">万里</option>
<option value="佳兴">佳兴</option>
</select>
</td>
</tr>
</table>
<table id=row3 style="display: none;">
<tr>
<td>
<select>
<option value="大里">大里</option>
<option value="白河">白河</option>
</select>
</td>
</tr>
</table>
</td>
<td>
<input name="addrother" type="text" id="addrother" size ="20">
</td>
</tr>
</table>
<input type="submit" value="传送">
</form>
</body>
<script language"javascript">
function getData(obj)
{
var d2 = document.getElementById("row2");
var d3 = document.getElementById("row3");
if(obj.value == 1)
{
d2.style.display = "block";
d3.style.display = "none"; //hidden
}
if(obj.value == 2)
{
d2.style.display = "none"; // hidden
d3.style.display = "block";
}
}
</script>
</html>
我身分证、密码这些资料都传得过去,就通讯地址传不过去(只传index而已)
※ 引述《[email protected] (飞)》之铭言:
: ※ 引述《[email protected] (Tabitha~)》之铭言:
: > 怎麽用form的input把值存起来呢?
: > 我的javascript类似:
: > http://www.javaworld.com.tw/jute/post/view?bid=34&id=99875&sty=3&age=0&tpg=1&ppg=1#99875
: > 是动态的下拉式选单
: > 所以我本来用的方法是:
: > submit给处理的jsp网页後
: > 利用 String 变数名称=request.getParameter("变数名称");取值
: > 但是取出来的值只是select的index而已,无法选择select 的value
: html <select> 在submit的时候一定是传value, 不可能传index.
: 一定是你哪里写错了或想错了。
: 把你的code post 上来看看。
: > (我已经想过用request.getParameterValues的方法了,还是行不通,而且还会出错)
: > 请问有人这个问题出在哪里吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.123.175.236