我有一个多行单选按钮,我希望子弹在内容的左侧(默认情况下)与单选按钮控件的顶部对齐.在XAML中最简单的方法是什么?
假设以下标记:
<fieldset>
<legend>Radio Buttons</legend>
<ol>
<li>
<input type="radio" id="x">
<label for="x"><!-- Insert multi-line markup here --></label>
</li>
<li>
<input type="radio" id="x">
<label for="x"><!-- Insert multi-line markup here --></label>
</li>
</ol>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
如何设置单选按钮标签的样式,使其在大多数浏览器中看起来如下(IE6 +,FF,Safari,Chrome:

如何使用NetBeans将单选按钮添加到按钮组?
添加后,如何从按钮组中选择单选按钮?
假设我们有一组通过Project服务公开的项目:
{ id: '123', name: 'Yeoman', watchers: '1233', ... }
{ id: '123', name: 'Grunt', watchers: '4343', ... }
Run Code Online (Sandbox Code Playgroud)
然后,我们有一个表单来选择您最喜欢的项目:
Select favorite project:
%label.radio(ng-repeat="project in Project.query()")
%input(type="radio" ng-model="data.favoriteProject" value="{{project.id}}") {{project.name}}
Run Code Online (Sandbox Code Playgroud)
这会将choices.favoriteProject设置为所选项目的id值.通常,我们需要访问相关对象,而不仅仅是id:
John's favorite project:
{{Project.get(data.favoriteProject).name}}
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是一种方法将无线电和复选框直接绑定到对象本身,而不是id,所以我们可以做
John's favorite project:
{{data.favoriteProject.name}}
Run Code Online (Sandbox Code Playgroud)
代替.这可以通过ng-options使用select指令,但是我们如何使用无线电和复选框来实现这一点?如果可能的话,我仍然想使用id来匹配而不是引用.
为了澄清,这是我正在寻找的一个例子
Select favorite project:
%label.radio(ng-repeat="project in Project.query()")
%input(type="radio" ng-model="data.favoriteProject" value="{{project}}" ng-match="id") {{project.name}}
Run Code Online (Sandbox Code Playgroud)
它说:"请将data.favoriteProject绑定到实际的项目对象,并使用id来检查它们是否匹配(而不是引用)".
我正在考虑第一次接触html语言时,我记得当我在寻找带有点的特定按钮时.它为您提供了一些选择,您只能选择其中一个.我发现它被称为单选按钮.我不知道"无线电"这个词是如何与这样的事情相关的,我认为是时候解开这个谜团了.
所以我的问题是......为什么它被称为单选按钮?
这个问题可能没有特定的目的,但我仍然很好奇.
谢谢
ps我不知道我应该用于问题的标签,所以任何改变的建议都会受到欢迎
我正在制作一个表格,我需要收音机输入.如何在onSubmit函数中获取已检查的无线电输入,正确的方法是什么?
这是我的代码,我myRadioInput-variable在提交时包含选项A或选项B:
React.createClass({
handleSubmit: function() {
e.preventDefault();
var myTextInput = this.refs.myTextInput.getDOMNode().value.trim();
var myRadioInput = "How ?";
},
render: function() {
return (
<form onSubmit={this.handleSubmit}>
<input type="text" ref="myTextInput" />
<label>
<span>Option A</span>
<input type="radio" name="myRadioInput" value="Option A"/>
</label>
<label>
<span>Option B</span>
<input type="radio" name="myRadioInput" value="Option B"/>
</label>
<input type="submit" value="Submit this"/>
</form>
)
}
});
Run Code Online (Sandbox Code Playgroud) 在我的FXML内部,我有这个:
<fx:define>
<ToggleGroup fx:id="toggleGroup1"/>
</fx:define>
<Menu fx:id="toggleProofView" text="%proofView">
<items>
<RadioMenuItem text="%hide"
selected="true"
onAction="#handleLoadComponent"
toggleGroup="toggleGroup1"/>`
Run Code Online (Sandbox Code Playgroud)
不知怎的,我得到了错误:
Unable to coerce toggleGroup1 to class javafx.scene.control.ToggleGroup
但为什么?
我要做的是创建一个Menu包含其中几个RadioMenuItem都在同一个ToggleGroup中的东西.如何将它们添加到FXML文件中的切换组?
我想建立一个条件结构(if-else) RadioButton
我希望在选择Radiobutton RB1时,此功能处于活动状态:
regAuxiliar = ultimoRegistro;
Run Code Online (Sandbox Code Playgroud)
当选择单选按钮RB2时,此功能有效:
regAuxiliar = objRegistro;
Run Code Online (Sandbox Code Playgroud)
抱歉我的英语,我是巴西人.
我已经传递了一个动态创建HTML的复杂应用程序.
问题是,前一个人不知道单选按钮的"名称"属性实际上是组关联.
有了以下标记,有没有办法把它们分成两组
<div>
<%-- would like this to be a seperate group without changing name--%>
<label class="radio-inline"><input type="radio" name="radio" value="1">Group 1 Option 1</label>
<label class="radio-inline"><input type="radio" name="radio" value="2">Group 1 Option 2</label>
<label class="radio-inline"><input type="radio" name="radio" value="3">Group 1 Option 3</label>
</div>
<div>
<%-- would like this to be a seperate group without changing name--%>
<label class="radio-inline"><input type="radio" name="radio" value="1">Group 2 Option 1</label>
<label class="radio-inline"><input type="radio" name="radio" value="2">Group 2 Option 2</label>
<label class="radio-inline"><input type="radio" name="radio" value="3">Group 2 Option 3</label>
</div>
Run Code Online (Sandbox Code Playgroud)
是否有任何div或任何我可以围绕他们分开分组?我尝试了字段集和图例但它没有效果.我知道我可以将每个人放在一个表格中,但之后他们不会全部提交.
在单选按钮中使用布尔数据的正确方法是什么.如果直接使用,这些值将从布尔值转换为字符串.
预加载的输入字段的JSON数据:
var question = [
{value: true, name: "Yes"},
{value: false, name: "Not this time"}
]
Run Code Online (Sandbox Code Playgroud)
单选按钮字段:
<input type="radio"
name="question"
onChange={this.state.onRadioChange}
value={this.state.question[0].value} /> {this.state.question[0].name}
<input type="radio"
name="question"
onChange={this.state.onRadioChange}
value={this.state.question[1].value} /> {this.state.question[1].name}
Run Code Online (Sandbox Code Playgroud)
onRadioChange的绑定:
onRadioChange: function(e) {
console.log(e.target.value);
}
Run Code Online (Sandbox Code Playgroud)
控制台日志显示所选值从布尔值转换为字符串.
处理这个问题的一种方法是在onRadioChange函数中添加一个额外的函数,将"true"/"false"字符串转换为布尔值,e.target.value但感觉有点麻烦.另外,仅使用'e.target.checked'将不起作用,因为在某些单选按钮组中,我有其他值而不是布尔值(需要通过).
一些通用且干净的解决方案是使用从REST转换为REST的常量值表.
是否有任何特殊的ReactJS方法可以做到这一点?也许不吧.