标签: radio-button

如何设置样式(css)单选按钮和标签?

鉴于下面的代码,我如何设置单选按钮的样式,并将所选单选按钮的标签设置为与其他标签不同?

<link href="http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css" rel="stylesheet">
<link href="http://yui.yahooapis.com/2.5.2/build/base/base-min.css" rel="stylesheet">

<div class="input radio">
  <fieldset>
    <legend>What color is the sky?</legend>
    <input type="hidden" name="color" value="" id="SubmitQuestion" />
    <input type="radio" name="color" id="SubmitQuestion1" value="1"  />
    <label for="SubmitQuestion1">A strange radient green.</label>
    <input type="radio" name="color" id="SubmitQuestion2" value="2"  />
    <label for="SubmitQuestion2">A dark gloomy orange</label>
    <input type="radio" name="color" id="SubmitQuestion3" value="3"  />
    <label for="SubmitQuestion3">A perfect glittering blue</label>
  </fieldset>
</div>
Run Code Online (Sandbox Code Playgroud)

另外,让我说明我使用yui css样式作为基础.如果你不熟悉他们,可以在这里找到:

这里有他们的文档:Yahoo!UI库

@pkaeding:谢谢.我尝试了一些漂浮的东西,只是看起来搞砸了.样式活动单选按钮似乎可以使用一些输入[type = radio]:谷歌搜索上的主动提名,但我没有让它正常工作.所以我想的问题更多:这在今天的所有现代浏览器中是否可行,如果不是,那么最小的JS需要什么?

html css styles radio-button

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

检测JRadioButton状态更改

当用鼠标单击时,如何检测JRadioButton何时从"未选定"更改为"选定"?我已经尝试在按钮上使用ActionListener,但是每次单击radiobutton时都会触发,而不仅仅是在将状态更改为"selected"时.

我想过维护一个布尔变量来记住按钮的状态,并在ActionListener中测试它以查看是否要更改其状态,但我想知道是否有更好或更清洁的解决方案.

java swing radio-button

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

单选按钮检查事件处理

在我的应用程序中,我需要一个无线电组,每当检查一个单选按钮时,就会发出警报,以便我可以使用jQuery将它的值发布到ajax帖子.

你能帮助我,请问我如何在jQuery中做到这一点?

jquery radio-button checked

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

如何取消选中已选中的单选按钮

事情是这个解决方案只在firefox中工作

$(':radio').on("change", function(event) {
  $(this).prop('checked', true);
});

$(':radio').on("click", function(event) {
  $(this).prop('checked', false);
});
Run Code Online (Sandbox Code Playgroud)

在chrome中,它不允许你选择任何东西 http://jsfiddle.net/wuAWn/

Ofc,我可以使用变量并写出类似的东西

var val = -1;
$(':radio').on("click", function() {
  if($(this).val() == val) {
    $(this).prop('checked', false);
    val = -1;
  }
  else val = $(this).val();
});
Run Code Online (Sandbox Code Playgroud)

但是我的页面上会有很少的单选按钮组,并且html内容是通过ajax加载的,所以我想为所有这些单元添加1个函数,而不是为每个单选按钮组定义变量并为每个单选按钮编写相同的函数组.

编辑:感谢您对复选框的帮助,但是对于充当单选按钮组的复选框,您需要编写adittional javascrip,取消选中具有相同名称的所有其他复选框onclick,我已经有单选按钮css,对我来说更容易添加像look-like-checkbox这样的类,让它看起来像复选框,我使用统一的库来定制外观,无论如何这里是我奇怪的解决方案http://jsfiddle.net/wuAWn/9/

javascript jquery radio-button

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

asp.net单选按钮分组

我目前遇到了单选按钮和分组的问题.我在转发器控件中有一个asp单选按钮.我将组名属性设置为"客户".页面加载时,单选按钮不会分组.它不是将id字段设置为组名,而是设置单选按钮的值字段.我知道我已经尝试在转发器控件之外设置单选按钮并且遇到了同样的问题.这里发生了什么?

ASPX

<asp:Repeater ID="repCustomers" runat="server">
    <HeaderTemplate>
        <table class="tableDefault" cellpadding="0" cellspacing="0" border="0" style="width: 383px; border: 0px !important">
            <tr>
                <th>&nbsp;</th>
                <th>Cust. No.</th>
                <th>Cust. Name</th>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
            <tr>
                <td>
                    <asp:RadioButton ID="radCustomer" GroupName="Customer" runat="server" ValidationGroup="Customer" ToolTip='<%#Eval("CustomerNumber") %>' />
                </td>
                <td><%#Eval("CustomerNumber")%></td>
                <td><%#Eval("Name") %></td>
            </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)

输出html

<table class="tableDefault" cellpadding="0" cellspacing="0" border="0" style="width: 383px; border: 0px !important">
    <tr>
        <th>&nbsp;</th>
        <th>Cust. No.</th>
        <th>Cust. Name</th>
    </tr>

    <tr>
        <td>
            <span title="111111"><input id="ctl00_PrimaryContent_repCustomers_ctl01_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl01$Customer" value="radCustomer" /></span>
        </td>
        <td>111111</td>
        <td>Jeremy's Test</td>
    </tr>

    <tr>
        <td>
            <span …
Run Code Online (Sandbox Code Playgroud)

asp.net repeater radio-button

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

用JQuery检查第一个单选按钮

我想查看每组的第一个单选按钮.但是有一些单选按钮被禁用,因此脚本应该忽略它们并转到下一个非禁用按钮.

我写了这样的东西,但它不起作用:

$(document).ready(function(){
if ($("input['radio']).is(':disabled'))
    {  
        $(this).attr('checked', false );
    }
else
    {
        $(this).attr('checked', true );
    }
});

非常感谢

jquery radio-button checked

29
推荐指数
4
解决办法
6万
查看次数

默认选中Angular 4默认单选按钮

我试图根据我从对象获得的值标记为默认的radiobutton,它可以是True或False.根据选项,我可以做什么来标记为默认的单选按钮?

<label>This rule is true if:</label>
<label class="form-check-inline">
    <input class="form-check-input" type="radio" name="mode" value="true" 
        [(ngModel)]="rule.mode"> all of the following conditions are true
</label>
<label class="form-check-inline">
    <input class="form-check-input" type="radio" name="mode" value="false"
        [(ngModel)]="rule.mode"> at least one of the following conditions is true
</label>
Run Code Online (Sandbox Code Playgroud)

我有真假rule.mode.

object radio-button angular-ng-if angular

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

RadioGroup有两列,有十个RadioButtons

我有一个RadioGroup,我想将两个列和五行中的按钮对齐,我无法实现它.我尝试过的事情:

  1. RelativeLayout- >外RadioGroup- >里面RadioGroup.所有RadioButtons都被选中,但我只想选择一个.
  2. RadioGroup :方向
  3. Span,stretchcolumns
  4. TableRow
  5. TableLayout

请让我知道如何创建一个RadioGroup并且有两列和多列RadioButtons.

android radio-group radio-button

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

如何根据给定的计数动态添加单选按钮?

我试过这个代码..当模拟器启动时,它会在一行中显示三个单选按钮.但我需要一个按钮事件.即; 如果我点击按钮,它应该询问单选按钮的数量.那么如果我给出计数,它必须根据给定的计数显示单选按钮.例如,如果我将计数设为3,则必须在一行中显示三个单选按钮.非常感谢您的帮助.提前致谢.

  public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        for(int row=0; row < 1; row++)
        {
            LinearLayout ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.HORIZONTAL);
            for(int i = 1; i < 4; i++) {
                RadioButton rdbtn = new RadioButton(this);
                rdbtn.setId((row * 2) + i);
                rdbtn.setText("Radio " + rdbtn.getId());
                ll.addView(rdbtn);
            }
            ((ViewGroup)findViewById(R.id.radiogroup)).addView(ll);
        }
    }
    }
Run Code Online (Sandbox Code Playgroud)

这是xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".MainActivity" >

    <RadioGroup …
Run Code Online (Sandbox Code Playgroud)

android dynamic count button radio-button

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

Android RadioButton textColor选择器

我有一个选择textColorRadioButton是这样的:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true" android:color="#fff"/>
    <item android:state_focused="true" android:color="#f00"/>
    <item android:state_pressed="true" android:color="#0f0"/>
    <item android:state_focused="false" android:state_pressed="false" android:color="#00f"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

我预计所选择的那个RadioButton将具有与其他颜色不同的颜色.

但是,所有RadioButtons都有蓝色文本(使用android:state_focused ="false"android:state_pressed ="false"),甚至是所选的.

我究竟做错了什么?

android radio-button

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