帆软单选按钮实例

In the old times, radios have some buttons to change stations that have saved to a specific button. HTML also provides radio buttons in order to one of the radio buttons in a group of them. Radio buttons in HTML are defined with the <input> tag because the Radio button is referred to as an input from the user.

在过去,收音机具有一些按钮来更改已保存为特定按钮的电台。 HTML还提供了单选按钮,以便于一组单选按钮中的一个。 HTML中的单选按钮是用<input>标记定义的,因为单选按钮被称为来自用户的输入。

单选按钮标签 (Radio Button Tag)

We will define a radio button with the <input> tag by providing the type as radio like below. Radio button tag does not have an enclosing tag like </input> etc.

我们将通过提供typeradiotype (如下所示)来定义带有<input>标签的单选按钮。 单选按钮标签没有像</ input>这样的封闭标签。

<input type="radio">

单选按钮组 (Radio Button Group)

Radio buttons generally used as a group. Because the main usage case for the radio button is providing some choices to the user and the user selects one of them. So we generally provide multiple radio buttons as a group. In or der to create groups the radio buttons name attribute should be the same for all radio buttons in the same group. For example, if we want to ask the user age range we have to use the same name for all radio buttons like below.

单选按钮通常作为一个组使用。 因为单选按钮的主要用法是向用户提供一些选择,然后用户选择其中之一。 因此,我们通常将多个单选按钮作为一组提供。 在创建组时,对于同一组中的所有单选按钮,单选按钮名称属性应相同。 例如,如果要询问用户年龄范围,则必须对所有单选按钮使用相同的名称,如下所示。

<html><body><h2>Radio Buttons</h2><form><input type="radio" name="age" value="b18"> Below 18<br><input type="radio" name="age" value="o18"> Between 18 and 65 <br><input type="radio" name="age" value="o65"> Over 65  </form></body>
</html>

Radio Button Group
单选按钮组

设置默认单选按钮选择(Set Default Radio Button Selection)

As one of the radio buttons is selected explicitly by the user the default behavior is all of the radio buttons are unselected. In some cases, we need to provide one radio button as selected by default. We can use checked attributed inside the input tag. In this example, we will provide the Between 18 and 65 selected o checked by default.

由于用户明确选择了其中一个单选按钮,因此默认行为是未选中所有单选按钮。 在某些情况下,我们需要提供一个默认选中的单选按钮。 我们可以在输入标记中使用checked属性。 在此示例中,我们将提供默认情况下选中的Between 18 and 65 o。

<html><body><h2>Radio Buttons</h2><form><input type="radio" name="age" value="b18" > Below 18<br><input type="radio" name="age" value="o18" checked> Between 18 and 65 <br><input type="radio" name="age" value="o65"> Over 65  </form></body>
</html>

Set Default Radio Button Selection
设置默认单选按钮选择

检查给定单选按钮是否已选中(Check If Given Radio Button Selected)

After selecting a radio button we can get or check selected radio button value in JavaScript. We can use different frameworks AngularJS, jQuery, etc but for simplicity, we will use plain JavaScript. We will get the values from the radio button name and iterate over it.

选择单选按钮后,我们可以获取或检查JavaScript中选定的单选按钮值。 我们可以使用不同的框架AngularJS,jQuery等,但是为简单起见,我们将使用纯JavaScript。 我们将从单选按钮名称中获取值并对其进行迭代。

<html><body><h2>Radio Buttons</h2><form><input type="radio" name="age" value="b18" > Below 18<br><input type="radio" name="age" value="o18" checked> Between 18 and 65 <br><input type="radio" name="age" value="o65"> Over 65  </form><br><input type=button onClick="ValidateForm()" value="Check Radio Buttons"><script type="text/javascript">function ValidateForm(){var radioButtons = document.getElementsByName("age");for(var i = 0; i < radioButtons.length; i++){if(radioButtons[i].checked == true){alert("You have selected"+radioButtons[i].value)}}}</script></body>
</html>


禁用单选按钮 (Disable Radio Button)

Radio buttons can be used in different scenarios with where in some cases they must be disabled. We can disable a radio button by using disabled attribute which will disable and prevent selection of the radio button. In this example, we will disable the Over 65 radio button.

单选按钮可以在不同的情况下使用,在某些情况下必须禁用它们。 我们可以通过使用disabled属性来禁用单选按钮,该属性将禁用和阻止选择单选按钮。 在此示例中,我们将禁用“ Over 65单选按钮。

<html><body><h2>Radio Buttons</h2><form><input type="radio" name="age" value="b18" align="left" > Below 18<br><input type="radio" name="age" value="o18" checked> Between 18 and 65 <br><input type="radio" name="age" value="o65" disabled> Over 65  </form><br></body>
</html>

Disable Radio Button
禁用单选按钮

单选按钮与复选框(Radio Button vs Check Boxes)

Like the radio button, there are also checkboxes that provide selection in multiple choices. The main difference between the radio button and checkbox is only a single radio button can be checked at one but multiple checkboxes can be checked without a problem.  So radio button suites to single answer questions like age, gender, yes/no, etc. where checkboxes can be sued multiple answer questions like team, schools, cities, etc.

像单选按钮一样,也有复选框提供多个选择。 单选按钮和复选框之间的主要区别在于,一次只能选中一个单选按钮,但可以无问题地选中多个复选框。 因此,单选按钮套件可用于回答单个答案问题,例如年龄,性别,是/否等。在这里,可以对复选框使用团队,学校,城市等多个回答问题。

翻译自: https://www.poftut.com/html-radio-button-tutorial-with-examples/

帆软单选按钮实例

帆软单选按钮实例_HTML单选按钮示例教程相关推荐

  1. angularjs 实例_AngularJS服务示例教程

    angularjs 实例 Today we will look at one of the important angular concepts called AngularJS Services. ...

  2. angularjs 实例_AngularJS包含示例教程

    angularjs 实例 Earlier we looked at custom directives and in this tutorial, we will discuss about the ...

  3. angularjs 实例_AngularJS过滤器示例教程

    angularjs 实例 We looked at View Model, View and Controller concepts in the previous post. Now we are ...

  4. jsf入门实例_JSF selectManyListBox示例教程

    jsf入门实例 JSF allows users to select multiple values for a single field with the help of <h:selectM ...

  5. 帆软单点登录_电子表格FineReport教程:[20]CAS单点登录

    若报表应用设置了权限,则需要将如下代码: package com.fr; import java.io.IOException; import java.io.PrintStream; import ...

  6. 帆软数据决策平台连接SAP RFC实例

    一.介绍 由于SAP ABAP开发出来的报表很单一,形式很有限,而且调整报表格式和形式都显得特别的鸡肋,所以现在将SAP系统通过RFC接口模式接入到帆软报表数据决策平台下展示.本文将详细介绍如何将数据 ...

  7. android实例教程_改造Android示例教程

    android实例教程 Welcome to Retrofit Android Example Tutorial. Today we'll use the Retrofit library devel ...

  8. 帆软地址栏传参,实例

    自动查询: http://help.finereport.com/finereport9.0/doc-view-409.html 参数的种类与区别: http://help.finereport.co ...

  9. 帆软报表动态数据源插件2.0使用教程

    1 动态数据源解决什么问题? 当我们遇到这种场景时,就可以使用动态数据源,我们有多个数据库,里面的某些表结构一样,只是数据不一样.当我们做报表的时候使用这些数据表,希望某些人能看到这个数据库的数据,另 ...

最新文章

  1. 【NCEPU】吴丹飞:(CSAPP)计算机系统漫游
  2. 医生再添新助手!深度学习诊断传染病 | 完整代码+实操
  3. 使用 Xmlrpc 来控制cobbler api
  4. Verilog中`define和parameter有什么区别
  5. windows和linux运算结果不同,从Windows和Linux读取文件会产生不同的结果(字符编码?)...
  6. 学计算机的快毕业要学论文吗,学计算机的好写毕业论文吗?
  7. java 集合 延迟加载_java-如何测试延迟加载的JPA集合是否已初始化?
  8. java 对象流传输socket_Java Socket(二)使用TCP传输对象
  9. 如何整理写作思路?MindManager在文章写作方面的应用
  10. Prism初研究之使用Prism 5.0开发模块化应用
  11. lsb算法 matlab隐藏图片算法,数字图像加密算法之空域LSB
  12. salesforce chatter提醒带Mention(即@)
  13. Linux useradd -M -s
  14. 视频号容易被官方封号的违规操作,你中招了吗?
  15. 微信自定义分享功能实现
  16. Oracle 字符集从GBK升级到Utf8
  17. Tushare的使用感受
  18. UVM——TLM通信(1)
  19. 网页详情页通用提取——通用新闻网站正文抽取器
  20. ps -ef 与 ps -eLf 的区别

热门文章

  1. 智明OA漏洞学习——EmailDownload.ashx 任意文件下载漏洞
  2. EPICS calc模块中aCalcout记录介绍
  3. 可以做外链的几个优质平台(哪里可以发外链)
  4. 雷蛇显示服务器,雷蛇(Razer)数据泄漏暴露了游戏玩家的个人信息
  5. Python笔记:利用pygame库实现一个俄罗斯方块小游戏(转载)
  6. 用Sygate实现单网卡共享上网
  7. 程序猿,你也配吃10元的盒饭?
  8. 游游学姐小分队part 2:跑马灯(位运算)
  9. 服务器开关电源型号ab和sb,SB21150AB 开关电源的PWM调整电流上升率
  10. 借助PD4ML将HTML转化成RTF或者PDF