Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 单选按钮工作不正常_Html_Radio Button - Fatal编程技术网

Html 单选按钮工作不正常

Html 单选按钮工作不正常,html,radio-button,Html,Radio Button,在我的网页中,我放置了一些单选按钮。但是这些按钮不能正常工作。我可以检查多个按钮 代码: xyz abc ccc 我只想检查一个按钮。请任何人帮助我。名称属性需要相同。名称将单选按钮组合在一起,使其成为一个单元 因为您对name属性有不同的值,所以它们应该有一个通用的name值,就像您对项目进行分组一样。。比如说 <input type="radio" name="group1" /> <input type="radio" name="group1" /> <

在我的网页中,我放置了一些单选按钮。但是这些按钮不能正常工作。我可以检查多个按钮

代码:

xyz
abc
ccc


我只想检查一个按钮。请任何人帮助我。

名称属性需要相同。名称将单选按钮组合在一起,使其成为一个单元

因为您对
name
属性有不同的值,所以它们应该有一个通用的
name
值,就像您对项目进行分组一样。。比如说

<input type="radio" name="group1" />
<input type="radio" name="group1" />
<input type="radio" name="group1" />

<!-- You can select any one from each group -->

<input type="radio" name="group2" />
<input type="radio" name="group2" />
<input type="radio" name="group2" />


分组在一起的单选按钮必须具有相同的区分大小写的
名称
属性

<label for="input1">First Input</label>
<input type="radio" id="input1" name="inputGroup" >
<label for="input2">Second Input</label>
<input type="radio" id="input2" name="inputGroup" >
<label for="input3">Third Input</label>
<input type="radio" id="input3" name="inputGroup" >
第一次输入
第二输入
第三输入

从:

单选按钮与复选框类似,不同之处在于当多个控件共享同一控件时,它们是互斥的


用同样的方式命名它们,在php或接收代码中类似

$_POST['name'] = 'value of selected radio button'
xyz
abc
ccc

所有输入必须具有相同的name=”“属性值

名称设置告知字段所属的单选按钮组。选择一个按钮时,将取消选择同一组中的所有其他按钮。 如果无法定义当前按钮所属的组,则每个页面上只能有一组单选按钮。 例如:

<input type="radio" name="fruit1" value="Apple"> Apple <br>
<input type="radio" name="fruit1" value="Apricot" checked> Apricot <br>
<input type="radio" name="fruit1" value="Avocado"> Avocado
<hr>
<input type="radio" name="fruit2" value="Banana"> Banana<br>
<input type="radio" name="fruit2" value="Breadfruit"> Breadfruit<br>
<input type="radio" name="fruit2" value="Bilberry" checked>  Bilberry
Apple
杏子
鳄梨
香蕉
面包果
欧洲越橘
为要从中选择一个选项的所有单选按钮指定相同的名称

<label for="abc" style="margin-top:-20px;margin-left:40px">xyz</label>
<input type="radio" id="abc" name="abc" >        
<label for="bcd" style="margin-top:-20px;margin-left:40px">abc</label>
<input type="radio" id="bcd" name="abc" >
<label for="efg" style="margin-top:-20px;margin-left:40px">ccc</label>
<input type="radio" id="efg" name="abc" >
xyz
abc
ccc

现在它将正常工作

为名称赋予相同的属性。
选中的属性可用于指示应选择的值。在您想要检查的值的语法中,write checked=“checked”

啊,伙计,这帮我省去了一些严重的挫折。有时候,回到基本面是很好的!非常感谢。
<input type="radio" name="fruit1" value="Apple"> Apple <br>
<input type="radio" name="fruit1" value="Apricot" checked> Apricot <br>
<input type="radio" name="fruit1" value="Avocado"> Avocado
<hr>
<input type="radio" name="fruit2" value="Banana"> Banana<br>
<input type="radio" name="fruit2" value="Breadfruit"> Breadfruit<br>
<input type="radio" name="fruit2" value="Bilberry" checked>  Bilberry
<label for="abc" style="margin-top:-20px;margin-left:40px">xyz</label>
<input type="radio" id="abc" name="abc" >        
<label for="bcd" style="margin-top:-20px;margin-left:40px">abc</label>
<input type="radio" id="bcd" name="abc" >
<label for="efg" style="margin-top:-20px;margin-left:40px">ccc</label>
<input type="radio" id="efg" name="abc" >