html表单性别单选(HTML中的单选按钮问题)

:暂无数据 2026-08-08 23:40:01 :0

html表单性别单选(HTML中的单选按钮问题)

“html表单性别单选”相关信息最新大全有哪些,这是大家都非常关心的,接下来就一起看看html表单性别单选(HTML中的单选按钮问题)!

本文目录

HTML中的单选按钮问题

value="male",value="female" 这个是用来在后台用的,页面是不显示的,也就是说当你提交form表单
的时候,在后台程序获取值时得到的就是“male”、“female”,就是你所选的那个

编写HTML注册表单, 需要字段: 用户名, 密码, 确认密码, 性别(单选), 城市(下拉列表), 兴趣爱好

源程序如下,二级的编程序啊,我这里都有保存原题答:《html》《head》《title》HTML注册表单《/title》《/head》《body》《form action="" method="post" onsubmit="return sub()" name=form》用户名:《input type="text" name="username" value="" /》《br》密码 《input type="password" name="password" value="" /》《br》确认密码:《input type="password" name="repassword" value="" /》《br》性别:《input type="radio" name="sex" value="0" checked=”default” /》男《input type="radio" name="sex" value="1" /》女《br》城市: 《select name="city"》《option value="0"》郑州《/option》《option value="1"》上海《/option》《option value="2"》天津《/option》《option value="3"》深圳《/option》《/select》《br》兴趣爱好:《input type="checkbox" name="read" value="0" /》阅读 《input type="checkbox" name="travel" value="1" /》旅游 《input type="checkbox" name="Internet" value="2" /》上网个人简介: 《textarea rows="5" cols="30" name="readme"》《/textarea》 《br》 《input type="submit" value="提交"/》 《/form》《/body》《/html》

form表单内部div块隐藏显示问题 想实现点击修改后出现单选框选择性别

《!DOCTYPE html》
《html lang="en"》
《head》
        《meta charset="UTF-8"》
    《script type="text/javascript"》
    function change1()
    {
        document.getElementById("sex0").style.display = "none";
        document.getElementById("sex1").style.display = "block";
    }
    《/script》
    
《/head》
《body》
《div 》
 《form  action="" method="post"》
            《div》
                《span》性别《/span》
                《div class="name_control" id="sex0" style="display: block"》
                    《span class="js-before"》男《/span》
                    《input type="button" style="border:none; background:white;" onclick="change1()" value="修改" /》
                    
                《/div》
                《div class="" style="display: none" id="sex1"》
                    《label class=""》《input type="radio"  name="gender" value="1"》 男《/label》
                    《label class=""》《input type="radio" name="gender" value="0"》 女《/label》
                《/div》
            《/div》
《/form》
《/div》
《/body》
《/html》

《button》在ie下只是按钮,但在其他浏览器上是submit,submit类的按钮按下后,会进行提交,并刷新页面,所以按钮按下后页面改变一瞬间又重置了。

编写一个表单页面census.html,让用户填写姓名、性别(男女选择)、兴趣(运动,读书,音乐,书法及其他)

表单:
《form action="doservlet" method="post"》
姓名:《input name="user_name"》《br》
性别《input type="radio" value="man" name="sex"》男 《input type="radio" value="women" name="sex"》女《Br /》
爱好:《input type="check" name="likes" value="运动" /》运动
《input type="check" name="likes" value="读书" /》读书
《input type="check" name="likes" value="音乐" /》音乐
《input type="check" name="likes" value="书法" /》书法
《/form》
servlet:
iimport java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
***隐藏网址***
***隐藏网址***
***隐藏网址***
public class doservlet extends HttpServlet {
/**
* Constructor of the object.
*/
public doservlet() {
super();
}
/**
* Destruction of the servlet. 《br》
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. 《br》
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("《!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"》");
out.println("《HTML》");
out.println(" 《HEAD》《TITLE》A Servlet《/TITLE》《/HEAD》");
out.println(" 《BODY》");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println(" 《/BODY》");
out.println("《/HTML》");
out.flush();
out.close();
}
/**
* The doPost method of the servlet. 《br》
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name = null;
String sex = null;
String likes = null;
name=request.getParameter("user_name");
sex=request.getParameter("sex");
likes=request.getParameterValues("likes");
request.getSession().setAttribute("user_name", name);
request.getSession().setAttribute("sex", sex);
request.getSession().setAttribute("like",likes);
//把请求过来的数据放在session里
response.sendRedirect("目的页");
//在目的页中通过session的 getAttribute方法取出来即可
out.flush();
out.close();
}
/**
* Initialization of the servlet. 《br》
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}

在html中,由单选框选择男生或者女生,然后确定,页面根据你的选择定位到男生主页或者女生主页

我来修改下楼上的代码
《select id = "sex"》 《option value="nan"》男《/option》 《option value="nv"》女《/option》 《/select》
《input type="button" value="确定" onclick="go();"》
《script》
function go(){
var sex = document.getElementById("sex").value;
if(sex==’nan’)
window.location = "./nan.html";
}else{
window.location = "./nv.html";
}
《/script》
ok了。。。

如果你还想了解更多这方面的信息,记得收藏关注本站。

html表单性别单选(HTML中的单选按钮问题)

本文编辑:admin

更多文章:


withdrawal(withdrawal是什么意思)

withdrawal(withdrawal是什么意思)

今天给各位分享withdrawal是什么意思的知识,其中也会对withdrawal是什么意思进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

2026年10月11日 07:00

根据流程图怎么编写程序(用c语言根据流程图写程序)

根据流程图怎么编写程序(用c语言根据流程图写程序)

大家好,今天小编来为大家解答以下的问题,关于根据流程图怎么编写程序,用c语言根据流程图写程序这个很多人还不知道,现在让我们一起来看看吧!

2026年10月11日 06:00

在from子句中可以出现(如何在from 子句中嵌套查询下面的语句在access中出错!)

在from子句中可以出现(如何在from 子句中嵌套查询下面的语句在access中出错!)

大家好,关于在from子句中可以出现很多朋友都还不太明白,不过没关系,因为今天小编就来为大家分享关于如何在from 子句中嵌套查询下面的语句在access中出错!的知识点,相信应该可以解决大家的一些困惑和问题,如果碰巧可以解决您的问题,还望

2026年10月11日 05:20

countif函数统计个数怎么用(countif函数怎么用 详解Excel中countif函数的使用方法)

countif函数统计个数怎么用(countif函数怎么用 详解Excel中countif函数的使用方法)

其实countif函数统计个数怎么用的问题并不复杂,但是又很多的朋友都不太了解countif函数怎么用 详解Excel中countif函数的使用方法,因此呢,今天小编就来为大家分享countif函数统计个数怎么用的一些知识,希望可以帮助到大

2026年10月11日 03:30

正则匹配数字之前的字符(正则表达式如何匹配前面是数字、中间是“/”、后面也是数字,就像2/3专业的模式)

正则匹配数字之前的字符(正则表达式如何匹配前面是数字、中间是“/”、后面也是数字,就像2/3专业的模式)

本篇文章给大家谈谈正则匹配数字之前的字符,以及正则表达式如何匹配前面是数字、中间是“/”、后面也是数字,就像2/3专业的模式对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问

2026年10月11日 03:00

register语言学(register语言学)

register语言学(register语言学)

“register语言学”相关信息最新大全有哪些,这是大家都非常关心的,接下来就一起看看register语言学(register语言学)!

2026年10月11日 01:40

系统架构设计师可以直接考吗(学生可以报名系统架构设计师吗)

系统架构设计师可以直接考吗(学生可以报名系统架构设计师吗)

“系统架构设计师可以直接考吗”相关信息最新大全有哪些,这是大家都非常关心的,接下来就一起看看系统架构设计师可以直接考吗(学生可以报名系统架构设计师吗)!

2026年10月11日 01:00

orlnsertbootmediinselected(我电脑开机显示这个是什么意思or insert boot media in select)

orlnsertbootmediinselected(我电脑开机显示这个是什么意思or insert boot media in select)

大家好,如果您还对orlnsertbootmediinselected不太了解,没有关系,今天就由本站为大家分享orlnsertbootmediinselected的知识,包括我电脑开机显示这个是什么意思or insert boot med

2026年10月10日 23:00

display的用法(display是什么意思 详解display的含义和用法)

display的用法(display是什么意思 详解display的含义和用法)

大家好,如果您还对display的用法不太了解,没有关系,今天就由本站为大家分享display的用法的知识,包括display是什么意思 详解display的含义和用法的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!

2026年10月10日 22:00

html全部居中代码(怎么让网页居中显示,html如何让网页居中)

html全部居中代码(怎么让网页居中显示,html如何让网页居中)

大家好,今天小编来为大家解答以下的问题,关于html全部居中代码,怎么让网页居中显示,html如何让网页居中这个很多人还不知道,现在让我们一起来看看吧!

2026年10月10日 21:10

最近更新

西数5000aakx(西数WD-5000AAKX-001CAO和西数800AAJS-00WAAO哪个做安装系统盘比较好)
2026-10-11 08:30:05 浏览:0
热门文章

标签列表