标签: radio-button

jquery启用/禁用基于radiobutton的文本框

在我的页面(jsp)中,我有一个radiobutton组和一个文本框(最初被禁用).

  • 每当用户点击单选按钮时,应启用文本框
  • 当用户点击其他一些单选按钮时,文本框应再次被禁用.

我可以使用下面的代码启用最初禁用的复选框.

$("#DevGroup_OTHER").click(function(){          
    $("#otherDevText").attr("disabled","");
})
Run Code Online (Sandbox Code Playgroud)

我的问题:

  • 但是我怎么能再次禁用文本框?
  • 使用jQuery有更简单的解决方案吗?

问候

checkbox jquery radio-button

13
推荐指数
2
解决办法
10万
查看次数

Rails:嵌套对象的单选按钮选择

我坚持这个简单的选择任务.我有这个型号:

#  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)

当我创建一个新的问题,我想指定不仅在嵌套形式contentQuestion,但即使是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)

nested-forms radio-button nested-attributes ruby-on-rails-3

13
推荐指数
3
解决办法
4779
查看次数

如何用图像替换替换单选按钮?

我想,而不是标准的单选按钮,为每个单选按钮使用不同的图像.对于选定的状态,我希望在图像周围出现边框.

我已经尝试为单选按钮制作图像标签然后隐藏按钮,但这似乎因某种原因而破坏了功能.

我也遇到过这篇文章:http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/我可能会以某种方式扭曲我的目的.

有更简单/更好的方法吗?

html css forms radio-button

13
推荐指数
3
解决办法
7万
查看次数

在C#中使用radioButtons的groupBox的事件处理程序

我在groupBox中有一些radionButtons,我需要做一些我可以称之为"radiobuttons.checked之一"的动作,或者从radiobutton中找出哪些索引被改变了.我试图在事件列表中找到它,但我找不到合适的事件.

编辑: 为了使它更清楚:我需要知道是否存在一些handel我将为goupBox编写处理程序方法而不是单个radioButton.我知道如何使用radiButton.checkedChanged,但它不是我发现的......或者不同我需要知道groupBox在监视这个groupBox中发生了什么的选项 - 我的意思是只有groupBox的处理程序.我发现处理程序"在组框中发生的事情"或者如果存在则相似.

它位于Visual Studio 2012 中的WFA(Windows Presentation Application)中.

c# groupbox event-handling radio-button

13
推荐指数
5
解决办法
5万
查看次数

如果选中无线电,则需要输入字段

只有在检查某个无线电时,我才能以某种方式将所需属性插入输入字段吗?

我有一个名为"梯度计"的输入字段,默认情况下不需要填充.但是,如果用户检查名为"梯形"的单选按钮,则需要填充"梯形仪表"字段.

我的输入如下:

<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)

javascript html5 onchange radio-button required

13
推荐指数
3
解决办法
3万
查看次数

jQuery组的单选按钮.change方法

我正在使用带有单选按钮的表单,该单选按钮是一组无线电的一部分,一次只能选择一个(单个选择没问题).其中一个无线电必须在每次选择不同的代码时.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)

仅当您单击"特殊无线电"无线电时,才会显示字符串更改.

jquery radio-button

13
推荐指数
1
解决办法
5万
查看次数

WPF RadioButton/ToggleButton样式

我想模仿一组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,但我很遗憾如何在上图中获得结果.

wpf styles radio-button togglebutton

13
推荐指数
1
解决办法
2万
查看次数

HTML + React:单选按钮卡在最初设置为"已检查"的按钮上

我有一组两个单选按钮,其中一个在加载页面时被检查.看来我无法将其改为第二个.如果重要的话,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)

html javascript html5 radio-button reactjs

13
推荐指数
3
解决办法
2万
查看次数

jquery javascript:选择单选按钮时执行操作

我有以下单选按钮,默认情况下都没有选中.

<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)

javascript jquery radio-button

12
推荐指数
2
解决办法
2万
查看次数

如何自定义列表首选项单选按钮

我已经在我的应用程序中自定义了所有的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除外

customization android radio-button listpreference

12
推荐指数
1
解决办法
1万
查看次数