web获取单选按钮中的数据

来源:互联网 发布:淘宝网美工培训 编辑:程序博客网 时间:2024/06/16 19:10

这里我们联系上文来介绍一下注册文件中的两个单选按钮,能让用户选择性别。

代码如下:

<%@ page language="java" contentType ="text/html; charset=gb2312" %>



<html>
<form action="radiocontain.jsp" method=post>
请输入账号:<input name="account" type="text"><BR>
请输入密码:<input name="password" type="password"><BR>
请您选择性别:
<input name="sex" type="radio" value="boy"checked> 男
<input name="sex" type="radio" value="girl"checked>女<BR>
<input type="submit" value="注册">
</form>

</html>


下面介绍一下获取数据的代码

<%@ page language="java" contentType ="text/html; charset=gb2312" %>


<html>
 <% 
 String sex=request.getParameter("sex");
 out.println("性别:"+sex);
 %>
</html>


0 0
原创粉丝点击