我有一个注册表单,其中包含2个下拉列表,其中一个更改取决于第一个下拉列表中的哪个选项被选中。单击提交按钮,表单中的所有值都成功传递,除了值在下拉列表中。
我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8" />
<title>Sign Up</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript">
function configureDropDownLists(ddl1,ddl2) {
var retail = new Array('Books','Computer Accessories','Electronics', 'Fashion','Others');
var dining = new Array('Asian','Chinese','French','Italian','Japanese','Korean','Western','Others');
switch (ddl1.value) {
case 'Retail':
document.getElementById(ddl2).options.length = 0;
for (i = 0; i < retail.length; i++) {
createOption(document.getElementById(ddl2), retail[i], retail[i]);
}
break;
case 'Dining':
document.getElementById(ddl2).options.length = 0;
for (i = 0; i < dining.length; i++) {
createOption(document.getElementById(ddl2), dining[i], dining[i]);
}
break;
default:
document.getElementById(ddl2).options.length = 0;
break;
}
}
function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}
</script>
</head>
<body style="background-color:#FFF">
<div id="container_register">
<div id="header_register"></div>
<div id="welcome_register">Register</div>
<div id="box_register">
<form id="RegForm" name="RegForm" method="POST" action="Register.php">
<table width="460" border="0" cellpadding="5" cellspacing="5">
<tr>
<td>Username*</td><td><input type="text" name="username" maxlength="30" size="30" required="required" /></td>
</tr>
<tr>
<td>Email*</td><td><input type="text" name="email" maxlength="30" size="30" required="required" /></td>
</tr>
<tr>
<td>Verify Email*</td><td><input type="text" name="vemail" maxlength="50" size="30" required="required" /></td>
</tr>
<tr>
<td>Password*</td><td><input type="password" name="password" maxlength="50" size="30" required="required" /></td>
</tr>
<tr>
<td>Verify Password*</td><td><input type="password" name="vpassword" maxlength="50" size="30" required="required" /></td>
</tr>
<tr>
<td>Business Name*</td><td><input type="text" name="bizname" maxlength="30" size="30" required="required" /></td>
</tr>
<tr>
<td>Verify Business Name*</td><td><input type="text" name="vbizname" maxlength="30" size="30" required="required" /></td>
</tr>
<tr>
<td>Business Type*</td>
<td>:
<select name="type" id="ddl" onchange="configureDropDownLists(this,'ddl2')">
<option value=""></option>
<option value="Retail">Retail</option>
<option value="Dining">Dining</option>
</select>
</tr>
<tr>
<td>Business SubType*</td>
<td>:
<select id="ddl2" name="subtype">
</select>
</td>
</tr>
<tr>
<td>Info</td><td><textarea name="info" rows="5" cols="24" maxlength="300"></textarea>
</tr>
<tr>
<td colspan="2"><input type="SUBMIT" name="Button" value="Register"></td>
</tr>
<tr>
<td colspan="2"><?PHP if(isset($errormsg)){echo"$errormsg";}?></td>
</tr>
<tr>
<td colspan="3"><font color="#FF0000"></font></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
提交表格后,我被引导到处理页面,其中我回显print_r($ POST),我得到了
Array ( [username] => uname [email] => email [vemail] => vemail [password] => pw [vpassword] => vpw [bizname] => name [vbizname] => vname [Button] => Register )
的问题: 的 如何在下拉列表和textarea中传递所选值的值?