ASP页中怎么判断选择的是男还是女?(单选按钮的使用)
<formname="form1"method="post"action="tijiao.asp"onsubmit="returnjudge()">昵称:<inputna...
<form name="form1" method="post" action="tijiao.asp" onsubmit="return judge()">昵称:<input name="nickname" type="text" id="nickname" size="13" maxlength="20">
性别:男
<input name="nan" type="radio" value="radiobutton" checked>
女
<input type="radio" name="nv" value="radiobutton">
出生日期:
<select name="year">
<option value="2002">2002</option>
<option value="2001" selected="selected">2001</option>
<option value="2000">2000</option>
</select>年
<select name="month">
<option selected="selected">09</option>
<option>10</option>
<option selected="selected">11</option>
<option>12</option>
</select>月
<select name="date">
<option value="03">03</option>
<option value="02">02</option>
<option value="01" selected="selected">01</option>
</select>日
我想将选中的值写到数据库中,在数据库中应该加一个什么字段,文本类型吗?用的ACCESS!
怎么写代码能选中它的值是那一个! 这我说的不太清楚!举个例子,像选择昵称的值用document.form1.nickname.value这都是昵称的值了!可以用RecordSet的AddNew方法加入数据库了!
可这单选框的该怎么弄和这菜单/列表类型的怎么写代码?往高手给指点一下!谢谢! 展开
性别:男
<input name="nan" type="radio" value="radiobutton" checked>
女
<input type="radio" name="nv" value="radiobutton">
出生日期:
<select name="year">
<option value="2002">2002</option>
<option value="2001" selected="selected">2001</option>
<option value="2000">2000</option>
</select>年
<select name="month">
<option selected="selected">09</option>
<option>10</option>
<option selected="selected">11</option>
<option>12</option>
</select>月
<select name="date">
<option value="03">03</option>
<option value="02">02</option>
<option value="01" selected="selected">01</option>
</select>日
我想将选中的值写到数据库中,在数据库中应该加一个什么字段,文本类型吗?用的ACCESS!
怎么写代码能选中它的值是那一个! 这我说的不太清楚!举个例子,像选择昵称的值用document.form1.nickname.value这都是昵称的值了!可以用RecordSet的AddNew方法加入数据库了!
可这单选框的该怎么弄和这菜单/列表类型的怎么写代码?往高手给指点一下!谢谢! 展开
2个回答
展开全部
性别:
男 <input type="radio" name="sex" value="1" checked>
女 <input type="radio" name="sex" value="0">
用js判断是选择的是男还是女的语句:
if(document.form1.sex[0].checked==true){
//男
}
if(document.form1.sex[1].checked==true){
//女
}
用asp获取到值的语句:
dim sex : sex = Request("sex")
'sex里的值是1(男)或0(女)
在数据库里建一个整型或字符型的字段存这个值就可以了,
从数据库读出来的时候,判断是1显示“男”,是0显示“女”。
男 <input type="radio" name="sex" value="1" checked>
女 <input type="radio" name="sex" value="0">
用js判断是选择的是男还是女的语句:
if(document.form1.sex[0].checked==true){
//男
}
if(document.form1.sex[1].checked==true){
//女
}
用asp获取到值的语句:
dim sex : sex = Request("sex")
'sex里的值是1(男)或0(女)
在数据库里建一个整型或字符型的字段存这个值就可以了,
从数据库读出来的时候,判断是1显示“男”,是0显示“女”。
参考资料: http://www.baidu.com
展开全部
<%
id=request("id")
group_id=request("group_id")
sql = "select * from admintable where id="&request("id")
set rs = conn.Execute(sql)
%>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" class="tbl1o1">
<form method="post" name="myform" action="?action=SaveEditMight">
<tr>
<td height="25" align="center" valign="middle" class="td1"><span class="STYLE15">编辑管理员</span><span class="STYLE2">〖<span class="STYLE15"><%=rs("name")%></span>〗</span><span class="STYLE15">权限</span></td>
</tr>
<tr>
<td height="25" class="td1o1">
<span class="STYLE6">说明:超级管理员可以越过所有权限。请慎重分配好每个管理员的权限。</span><br>
<span class="STYLE2">
<input name="chkAll2" type="checkbox" id="chkAll" onClick=SelectAll(this.form) value="checkbox" >
选择所有权限
<%
if group_id<>"" then
sqlhh = "select id,Might from admin_group where id="&group_id&""
set rshh = conn.Execute(sqlhh)
Might=rshh("Might")
g_id=rshh("id")
rshh.close
set rshh=nothing
else
Might=rs("Might")
g_id=rs("GroupID")
end if
%>
<%
sqlh = "select id,groupname from admin_group order by border desc"
set rsh = conn.Execute(sqlh)
if not (rsh.bof and rsh.eof) then
do while not rsh.eof
%>
<input name="checkgroup" type="radio" value="<%=rsh("id")%>" onmouseover="location.href='manageadmin.asp?action=Edit_Might&id=<%=request("id")%>&group_id=<%=rsh("id")%>'" <%if rsh("id")=g_id then response.write "checked" %> >
<%=rsh("groupname")%>
<%
rsh.movenext
loop
end if
rsh.close
set rsh=nothing
%>
</span>
</td>
</tr>
<tr>
<td height="25" class="td1o1">
<span class="STYLE21">
<%
n = 0
for i=0 to ubound(MightList,1)
Response.Write "<br><br><b><font color='red'>"&MightList(i,0)&"</font></b><br>"
for j=1 to ubound(MightList,2)
if isempty(MightList(i,j)) then exit for
tmpmenu=split(MightList(i,j),"@@")
menuname=tmpmenu(0)
menurl=tmpmenu(1)
n = n+1
%>
<input type="checkbox" name="Might" id="Might" value="<%=menurl%>" <% if instr(","& Might &",",","& menurl &",")>0 then response.write "checked" %>><%=menurl%>. <%=menuname%>
<%
next
%>
<%next%>
</span>
id=request("id")
group_id=request("group_id")
sql = "select * from admintable where id="&request("id")
set rs = conn.Execute(sql)
%>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" class="tbl1o1">
<form method="post" name="myform" action="?action=SaveEditMight">
<tr>
<td height="25" align="center" valign="middle" class="td1"><span class="STYLE15">编辑管理员</span><span class="STYLE2">〖<span class="STYLE15"><%=rs("name")%></span>〗</span><span class="STYLE15">权限</span></td>
</tr>
<tr>
<td height="25" class="td1o1">
<span class="STYLE6">说明:超级管理员可以越过所有权限。请慎重分配好每个管理员的权限。</span><br>
<span class="STYLE2">
<input name="chkAll2" type="checkbox" id="chkAll" onClick=SelectAll(this.form) value="checkbox" >
选择所有权限
<%
if group_id<>"" then
sqlhh = "select id,Might from admin_group where id="&group_id&""
set rshh = conn.Execute(sqlhh)
Might=rshh("Might")
g_id=rshh("id")
rshh.close
set rshh=nothing
else
Might=rs("Might")
g_id=rs("GroupID")
end if
%>
<%
sqlh = "select id,groupname from admin_group order by border desc"
set rsh = conn.Execute(sqlh)
if not (rsh.bof and rsh.eof) then
do while not rsh.eof
%>
<input name="checkgroup" type="radio" value="<%=rsh("id")%>" onmouseover="location.href='manageadmin.asp?action=Edit_Might&id=<%=request("id")%>&group_id=<%=rsh("id")%>'" <%if rsh("id")=g_id then response.write "checked" %> >
<%=rsh("groupname")%>
<%
rsh.movenext
loop
end if
rsh.close
set rsh=nothing
%>
</span>
</td>
</tr>
<tr>
<td height="25" class="td1o1">
<span class="STYLE21">
<%
n = 0
for i=0 to ubound(MightList,1)
Response.Write "<br><br><b><font color='red'>"&MightList(i,0)&"</font></b><br>"
for j=1 to ubound(MightList,2)
if isempty(MightList(i,j)) then exit for
tmpmenu=split(MightList(i,j),"@@")
menuname=tmpmenu(0)
menurl=tmpmenu(1)
n = n+1
%>
<input type="checkbox" name="Might" id="Might" value="<%=menurl%>" <% if instr(","& Might &",",","& menurl &",")>0 then response.write "checked" %>><%=menurl%>. <%=menuname%>
<%
next
%>
<%next%>
</span>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询