关于CHECKBOX提交的问题,搞了我2天,希望得到满意的回答!
就是些CHECKBOX的框,如果一个都不选,就找不到这个对象,很麻烦
蠢办法就是给默认选项,可是这对以后的操作就不方便了
前台代码: <body>
<form id= "Form " name= "Form " runat= "server ">
<table>
<tr>
<td align= "left " width= "25% "> <input name= "General " value= "Baby Sitting " type= "checkbox "> Baby Sitting </td>
<td align= "left " width= "25% "> <input name= "General " value= "Beach Chairs " type= "checkbox "> Beach Chairs </td>
<td align= "left " width= "25% "> <input name= "General " value= "Beach Towels " type= "checkbox "> Beach Towels </td>
</tr> <tr>
<td align= "left " width= "25% "> <input name= "General " value= "Ceiling Fans " type= "checkbox "> Ceiling Fans </td>
<td align= "left " width= "25% "> <input name= "General " value= "Cot " type= "checkbox "> Cot </td>
<td align= "left " width= "25% "> <input name= "General " value= "Fireplace " type= "checkbox "> Fireplace </td>
<td align= "left " width= "25% "> <input name= "General " value= "Heating " type= "checkbox "> Heating </td>
</tr> <tr>
<td align= "left " width= "25% "> <input name= "General " value= "Highchair " type= "checkbox "> Highchair </td>
<td align= "left " width= "25% "> <input name= "General " value= "Indoor Pool " type= "checkbox "> Indoor Pool </td>
<td align= "left " width= "25% "> <input name= "General " value= "Linen Provided " type= "checkbox "> Linen Provided </td>
<td align= "left " width= "25% "> <input name= "General " value= "Maid service " type= "checkbox "> Maid service </td>
</tr> <tr>
<td align= "left " width= "25% "> <input name= "General " value= "Medical Facilities " type= "checkbox "> Medical Facilities </td>
<td align= "left " width= "25% "> <input name= "General " value= "Minibus Service " type= "checkbox "> Minibus Service </td>
<td align= "left " width= "25% "> <input name= "General " value= "Outside Pool " type= "checkbox "> Outside Pool </td>
<td align= "left " width= "25% "> <input name= "General " value= "Patio Furniture " type= "checkbox "> Patio Furniture </td>
</tr> <tr>
<td align= "left " width= "25% "> <input name= "General " value= "Pushchair " type= "checkbox "> Pushchair </td>
<td align= "left " width= "25% "> <input name= "General " value= "Telephone " type= "checkbox "> Telephone </td>
<tr>
<td class= "subheading " align= "center "> <input value= "Add Property " class= "button " type= "button " onclick= "add() "> </td>
</tr>
</table> </form>
</body>
</html>
<script type= "text/javascript ">
function add()
{
document.Form.action= "http://localhost:2505/WebSite2/Default.aspx?action=add ";
document.Form.submit();
}
</script>
[解决办法]
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString[ "action "] == "add ")
{
try
{
string[] keys = Request.Form.AllKeys;
foreach(string k in keys)
{
if (k == "General ")
{
string _General = Request.Form[ "General "].ToString();
Response.Write( " <script language=javascript> alert( ' " + Request.Form[ "General "] + " '); </script> ");
break;
}
}
}
catch (Exception ex)
{
throw (ex);
}
}
}