简体   繁体   English

单选按钮以启用数字类型

[英]radio button to enable number type

I have to enable a number type box when a (Qty)radio button is clicked.And disable when (rate) radio button is clicked. 单击(数量)单选按钮时必须启用数字类型框,单击(费率)单选按钮时必须禁用数字类型框。

my view 我的观点

 <input type="radio" class="radioBtn" name="quantity" value="yes" id="rad1" onclick="radio()"/>PRN
    <input type="radio" class="radioBtn" name="quantity" value="no" id="rad2"  onclick="radio()" />Qty
     <input type="number" name="someid" id="textfield" disabled/> 

my javascript 我的JavaScript

 $(".radioBtn").click(function radio() {
            $("#textfield").attr("disabled", true);
            if ($("input[name=quantity]:checked").val() == "yes") {
                $("#textfield").removeattr("disabled");
            }

    });

my link to connect view and js 我的链接来连接视图和js

I'm not sure if this will work on your end but seems good here. 我不确定这是否对您有用,但在这里看起来不错。 Just change removeattr to removeAttr 只需将removeattr更改为removeAttr

$("#textfield").removeAttr("disabled");

Also make sure you're including JQuery in your site. 还要确保在您的站点中包括JQuery。 For a better insight into why something might not be working, press F12 to open the console in a browser. 为了更好地了解为什么某些功能可能无法正常工作,请按F12键在浏览器中打开控制台。 This will show any errors. 这将显示任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM