标签: radio-button

如果使用jquery选中单选按钮,如何执行javascript确认对话框

我有两个单选按钮

<input type="radio" name="rush" value="yes" />
<input type="radio" name="rush" value="no" checked="checked" />
Run Code Online (Sandbox Code Playgroud)

我想要做的是当单击表单提交按钮时,检查是否选择了"是".

如果是,则显示一个javascript确认对话框

我已经走到了这一步,但我被卡住了,任何帮助都会受到赞赏.

$("form.shipping").submit(function() {

    if($("input[name='rush']".attr("value") === "yes")
    {
        if (confirm("Rush orders are subject to an upcharge. (Just wanted to make sure you read the note). Is this ok?"))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

});
Run Code Online (Sandbox Code Playgroud)

validation jquery webforms radio-button

0
推荐指数
1
解决办法
4316
查看次数

如何正确检查输入的值?

我做了一个小测验,但我在单击下一步按钮时遇到了最后一个问题,它会检查该值是否未找到。如果它是真的,它会检查客户选择的收音机是否等于配偶的正确答案,然后 var correctAnswer 获得 +1。问题在于,在第一个问题中它起作用(检查客户是否真的从答案中选择了一些内容并检查其是否正确)但是当提出下一个问题时它不起作用。我试图弄明白,但没有sulotion来......还要检查的jsfiddle:http://jsfiddle.net/boazmier/ru8Qj/1/ 我试图把checkClientChoice功能到loadquestion功能它没有工作,以及

var allQuestions = {
    question: {
        question0: {
            question: "Who is the first Prime Minister of Israel?",
            choices: ["David", "Rabin", "Peres", "Bibi"],
            correct: "David"
        },
        question1: {
            question: "What Is israel date of birth?",
            choices: ["1948", "1958", "1950", "1944"],
            correct: "1948"
        },
        question2: {
            question: "What is PhoneGap framework for?",
            choices: ["apache", "apps", "server", "client"],
            correct: "apps"
        }
    },

    correctAnswer: 0
};

var allquestion = allQuestions["question"];

var calcAnswers =allQuestions["correctAnswer"];

var qNum = 0; …
Run Code Online (Sandbox Code Playgroud)

javascript jquery input radio-button

0
推荐指数
1
解决办法
73
查看次数

单击单选按钮不会使用jquery发出警报

单击单选按钮没有任何反应,为什么?

<html>
    <head>
        <link type="text/css" rel="stylesheet" href="css/bootstrap.css" />
        <script type="text/javascript" src="jquery.js">          
            $("input[name='check1']",$('#Search_By')).change(function()
            {
                alert('yo');
            });
        </script>
    </head>
    <body class="well">
        <form action="/abc/readservlet" method="post">
            <div class="well" id="Search_By">
                <h3><b/>Search BY</h3>
                <input type="Radio" name="check1" value="Search BY Key"> Key<br/><br/>
                <input type="Radio" name="check1" value="Search By Tablename"> Tab_name         
                <br/>
            </div>
Run Code Online (Sandbox Code Playgroud)

点击单选按钮没有任何反应......

html javascript jquery radio-button

0
推荐指数
1
解决办法
117
查看次数

如何使用cfform内置验证验证是否选择了单选按钮?

假设我有一个看起来像这样的简单cfform:

<cfform id="fruitForm" method="post" action="">
    <cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" /><label for="fruit_apple">Apple</label><br />
    <cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" /><label for="fruit_orange">Orange</label><br />
    <cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" /><label for="fruit_pear">Pear</label><br />

    <cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
Run Code Online (Sandbox Code Playgroud)

如何使用内置的cfform验证来确保选择此组中的至少一个单选按钮?我尝试在每个单选按钮上添加一个validate ="required"但它不起作用.有没有简单的方法来"要求"使用cfform验证选择其中一个按钮?

validation coldfusion cfform radio-button

0
推荐指数
1
解决办法
2932
查看次数

如何使用jquery和ajax检查和取消选中单选按钮?

我正在使用ajax加载动态生成的单选按钮,当我尝试取消选中单选按钮时,我不知道它是如何工作的.所以有人可以帮助我吗?

这是动态生成的HTML代码:

enter code here
<table cellepadding='15' cellspacing='15' border='1' class='gridtable' align='center'>
<tr>
<td><strong>Service Name</strong></td>
<td><strong>Daily</strong>
<td><strong>Weekly</strong></td>
<td><strong>BiMonthly</strong></td>
<td><strong>Monthly</strong></td>
</tr>

<tr>
<td>Inspection & Reporting</td>
<td>NA</td>
<td align="center">
<input type="radio" id="215" name="1" value="1/215" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>50</strong></td>
<td><input type="radio" id="200" name="1" value="2/200" onclick="DisplayPrice(this.id);" class="radio"/>  <br> Rs. <strong>100</strong></td>
<td align="center"><input type="radio" id="200" name="1" value="3/200" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>200</strong></td>
</tr>

<tr>
<td>House keeping/Cleaning</td>
<td>NA</td>
<td align="center"><input type="radio" id="322.5" name="2" value="7/322.5" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>75</strong></td>
<td><input type="radio" id="300" name="2" value="8/300" onclick="DisplayPrice(this.id);" class="radio"/> …
Run Code Online (Sandbox Code Playgroud)

jquery radio-button uncheck

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

如何在 Windows 窗体中动态添加单选按钮?

我需要在 Windows 窗体和水平模式下动态添加单选按钮。 样本

for (int i = 0; i <= r.Count; i++)
{
RadioButton rdo = new RadioButton();
rdo.Name = "id";
rdo.Text = "Name";
rdo.ForeColor = Color.Red;
rdo.Location = new Point(5, 30 );
this.Controls.Add(rdo);
}
Run Code Online (Sandbox Code Playgroud)

c# radio-button winforms

0
推荐指数
1
解决办法
8060
查看次数

LibreOffice:如何创建单选按钮组

在LibreOffice Writer文档中,如何创建单选按钮组? 我无法将按钮“分组”。

我正在使用LibreOffice 5.3.4.2(x64)。

我在Writer文档中放置了多个单选按钮控件。

我选择两个按钮,然后在控件的“属性”中为它们分配相同的组名。

我选择了另外两个按钮,并为其分配了自己的相同组名。

范例

“你喜欢狗吗?是的,不是。” (这些将是“ ”组)

“你讨厌猫吗?哦,是的,不是。” (这些将是“ ”组)

我将PDF导出为表单,然后在Adobe Acrobat中打开它。

按钮在那里,但组不是分开的。这些组不是互斥的,即使在一个组内,选项也不是互斥的。

问题可能出在单个按钮或组的命名上,但是解决方案使我难以理解。咨询Google先生没有帮助。

有什么帮助吗?

forms controls radio-group radio-button libreoffice

0
推荐指数
1
解决办法
1356
查看次数

如何在单选按钮中放置文本?

我试图把一个单选按钮,里面的信件(Materialise的框架),这在像A和B的图像

我该怎么做呢?

css radio-button materialize

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

Android 自定义单选按钮

我想制作自定义单选按钮。我为正常(radio_normal)状态创建了一个drawable。但我发现很难为选中状态(radio_pressed)创建一个形状。我尝试过创建我想要的方式。但没有成功好吧。我不知道我是否做对了。对于检查状态,形状应该是这样的。外边框和内圈必须是白色的。有人可以帮我吗?

radio_normal:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:useLevel="false">
    <solid
        android:color="#2196f3"></solid>

</shape>
Run Code Online (Sandbox Code Playgroud)

radio_pressed:

 <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape android:shape="oval"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <solid
            android:color="@android:color/transparent">
        </solid>
        <size
             android:height="60dp"
            android:width="60dp">
       </size>
      <stroke
          android:color="#ffffff"
          android:width="1dp"
          >
    </stroke>
    </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid
                    android:color="#ffffff">
                </solid>
            </shape>
            <size
                android:height="30dp"
                android:width="30dp">
    </size>
        </item>
    </layer-list>
Run Code Online (Sandbox Code Playgroud)

radio_bg:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:state_checked="true"
    android:drawable="@drawable/radio_pressed"
    >
</item>
    <item
        android:state_checked="false"
        android:drawable="@drawable/radio_normal"
        >
    </item>
</selector>
Run Code Online (Sandbox Code Playgroud)

活动_主要:

<RadioButton
        android:id="@+id/radio"
        android:layout_centerInParent="true"
        android:layout_width="10dp"
        android:button="@drawable/radio_bg"
        android:layout_marginTop="100dp"
        android:layout_height="10dp"
        />
Run Code Online (Sandbox Code Playgroud)

android radio-button

0
推荐指数
1
解决办法
6030
查看次数

jQuery:如何为多组单选按钮重用相同的功能

我有一个HTML表单,其中包含格式为单选按钮的多选答案的问题.

当用户对其中一个问题回答"是"时,会显示补充问题.该功能检测单选按钮输入的"是"值.

如果我需要在用户回答"是"时显示一个额外的问题,我可以在其他"是"/"否"问题上重复使用相同的功能 - 我只需将"切换"类应用于无线电输入,然后设置data-target用于匹配我想要显示的隐藏问题块的ID 的属性.

但是,我无法在表单中的其他问题上重复使用相同的功能,因为大多数问题没有"是"/"否"答案.大多数输入值属性都是唯一的.

如何使函数可重用,以便我可以在任何问题上应用相同的"toggle"类以显示目标块,而不是为每个需要补充问题的答案创建单独的函数?

下面是表单的简化示例 - 只有四个示例问题.第一个和最后一个问题具有是/否答案值,另外两个问题具有不同的答案值:

$(document).ready(function() {
  $("input.toggle:radio").change(function() {
    if ($(this).val() == "yes") {
      $("#" + $(this).data("target")).slideDown();
    } else {
      $("#" + $(this).data("target")).slideUp();
    }
  });
});
Run Code Online (Sandbox Code Playgroud)
.extra {
  display: none;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<form>
  <div class="question">
    <p><b>Question 1: Do you have a driving licence?</b></p>
    <label><input type="radio" class="toggle" name="question1" value="no" data-target="extra-box1"> No</label>
    <label><input type="radio" class="toggle" name="question1" value="yes" data-target="extra-box1"> Yes</label>
    <div id="extra-box1" class="extra"><i>If user clicks 'Yes', show this block</i></div>
  </div>
  
  <div class="question">
    <p><b>Question 2: …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery radio-button

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