Re: [JSP ] 問一下關於傳值的問題
<%@ 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而已)
※ 引述《feicsh.bbs@bbs.wretch.cc (飛)》之銘言:
: ※ 引述《bigtq13.bbs@ptt.cc (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
討論串 (同標題文章)
java 近期熱門文章
PTT數位生活區 即時熱門文章