在我的页面(jsp)中,我有一个radiobutton组和一个文本框(最初被禁用).
我可以使用下面的代码启用最初禁用的复选框.
$("#DevGroup_OTHER").click(function(){
$("#otherDevText").attr("disabled","");
})
Run Code Online (Sandbox Code Playgroud)
我的问题:
问候
我坚持这个简单的选择任务.我有这个型号:
# id :integer(4) not null, primary key
# category :string(255)
# content :text
class Question < ActiveRecord::Base
has_many :choices, :dependent => :destroy
accepts_nested_attributes_for :choices
end
# id :integer(4) not null, primary key
# content :text
# correct :boolean(1)
# question_id :integer(4)
class Choice < ActiveRecord::Base
belongs_to :question
end
Run Code Online (Sandbox Code Playgroud)
当我创建一个新的问题,我想指定不仅在嵌套形式content的Question,但即使是content3个的Answer对象,并用一个单选按钮哪一个是选择correct答案.在new控制器的动作中,我有这个:
def new
@title = "New Question"
@question = Question.new
3.times { @question.choices.build }
respond_to do |format|
format.html # …Run Code Online (Sandbox Code Playgroud) 我想,而不是标准的单选按钮,为每个单选按钮使用不同的图像.对于选定的状态,我希望在图像周围出现边框.
我已经尝试为单选按钮制作图像标签然后隐藏按钮,但这似乎因某种原因而破坏了功能.
我也遇到过这篇文章:http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/我可能会以某种方式扭曲我的目的.
有更简单/更好的方法吗?
我在groupBox中有一些radionButtons,我需要做一些我可以称之为"radiobuttons.checked之一"的动作,或者从radiobutton中找出哪些索引被改变了.我试图在事件列表中找到它,但我找不到合适的事件.
编辑: 为了使它更清楚:我需要知道是否存在一些handel我将为goupBox编写处理程序方法而不是单个radioButton.我知道如何使用radiButton.checkedChanged,但它不是我发现的......或者不同我需要知道groupBox在监视这个groupBox中发生了什么的选项 - 我的意思是只有groupBox的处理程序.我发现处理程序"在组框中发生的事情"或者如果存在则相似.
它位于Visual Studio 2012 中的WFA(Windows Presentation Application)中.
只有在检查某个无线电时,我才能以某种方式将所需属性插入输入字段吗?
我有一个名为"梯度计"的输入字段,默认情况下不需要填充.但是,如果用户检查名为"梯形"的单选按钮,则需要填充"梯形仪表"字段.
我的输入如下:
<input type="text" name="ladder-meters" id="ladder-meters">
Run Code Online (Sandbox Code Playgroud)
并且应该在收音机的onchange事件中这样做
<input type="text" name="ladder-meters" id="ladder-meters" required>
Run Code Online (Sandbox Code Playgroud) 我正在使用带有单选按钮的表单,该单选按钮是一组无线电的一部分,一次只能选择一个(单个选择没问题).其中一个无线电必须在每次选择不同的代码时.change触发代码(当选择另一个无线电时),即时使用方法并在单击时触发代码,但是当它失去选择时则不会.我想要的是切换或能够知道何时失去选择.
我可以把它添加到其他无线电.change方法的代码,但有很多套无线电,这将是痛苦的,我正在寻找一次性配置.
编辑
标记是由ASP MVC Razor引擎组成的,如下所示:
@Html.RadioButtonFor(x => x.SomeModel, new { @class = "special-radio" })
@* Other radios but without the 'specia-radio' class *@
Run Code Online (Sandbox Code Playgroud)
JS:
// logging
$(function(){
$('.special-radio').change(function(){
console.log('change');
});
});
Run Code Online (Sandbox Code Playgroud)
仅当您单击"特殊无线电"无线电时,才会显示字符串更改.
我想模仿一组ToggleButtons的样式,如下图所示.任何时候只能"检查"其中一个按钮.

我的问题与样式有关:
我正在使用的当前控件是这样完成的:
<StackPanel Orientation="Horizontal" >
<RadioButton Style="{StaticResource {x:Type ToggleButton}}" Content="All" Padding="12,8,12,8" GroupName="View" />
<RadioButton Style="{StaticResource {x:Type ToggleButton}}" Content="Geolocated" Padding="12,8,12,8" GroupName="View" />
<RadioButton Style="{StaticResource {x:Type ToggleButton}}" Content="Non Geolocated" Padding="12,8,12,8" GroupName="View" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
在StackPanel资源中,我试图为ToggleButton设置Style,但我很遗憾如何在上图中获得结果.
我有一组两个单选按钮,其中一个在加载页面时被检查.看来我无法将其改为第二个.如果重要的话,HTML由reactjs构建.chrome上的标记看起来像:
<fieldset data-reactid=".0.0.0.0.0.0.1">
<label for="coop-radio-btn" data-reactid=".0.0.0.0.0.0.1.0">
<span data-reactid=".0.0.0.0.0.0.1.0.0">To a Cooperative</span>
<input type="radio" name="requestOnBehalfOf" value="coop" id="coop-radio-btn" data-reactid=".0.0.0.0.0.0.1.0.1">
</label>
<label for="union-radio-btn" data-reactid=".0.0.0.0.0.0.1.1">
<span data-reactid=".0.0.0.0.0.0.1.1.0">Additional Request</span>
<input type="radio" name="requestOnBehalfOf" value="union" checked="" id="union-radio-btn" data-reactid=".0.0.0.0.0.0.1.1.1">
</label>
</fieldset>
Run Code Online (Sandbox Code Playgroud) 我有以下单选按钮,默认情况下都没有选中.
<input type="radio" name="location" value="0" /> home
<input type="radio" name="location" value="1" /> work
<input type="radio" name="location" value="2" /> school
Run Code Online (Sandbox Code Playgroud)
如何检测其中任何一个被检查.我正在寻找像点击这样的东西,但它不起作用
$("input[name=location]").click(function(){
alert("selected");
});
Run Code Online (Sandbox Code Playgroud) 我已经在我的应用程序中自定义了所有的radioButtons,但listPreference中的radioButtons没有自定义.
我使用了这个名为btn_radio.xml的xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/radio_selected" />
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/radio_unselected" />
<item android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/radio_selected" />
<item android:state_checked="false" android:state_pressed="true"
android:drawable="@drawable/radio_unselected" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/radio_selected" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/radio_unselected" />
<item android:state_checked="false" android:drawable="@drawable/radio_unselected" />
<item android:state_checked="true" android:drawable="@drawable/radio_selected" />
</selector>
Run Code Online (Sandbox Code Playgroud)
这是customRadioButton,它扩展了android自定义单选按钮
<style name="CustomRadioButton" Parent="@android:style/Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/btn_radio</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在我的应用程序的主题中,我做了这个改变
<item name="android:radioButtonStyle">@style/CustomRadioButton</item>
<item name="android:listChoiceIndicatorSingle">@style/CustomRadioButton</item>
Run Code Online (Sandbox Code Playgroud)
此更改会自定义我的应用程序中的所有radioButtons,但ListPreference中的radioButtons除外
radio-button ×10
javascript ×3
jquery ×3
html ×2
html5 ×2
android ×1
c# ×1
checkbox ×1
css ×1
forms ×1
groupbox ×1
nested-forms ×1
onchange ×1
reactjs ×1
required ×1
styles ×1
togglebutton ×1
wpf ×1