Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在单选按钮之间建立关系?_Javascript_Jquery_Radio Button - Fatal编程技术网

Javascript 如何在单选按钮之间建立关系?

Javascript 如何在单选按钮之间建立关系?,javascript,jquery,radio-button,Javascript,Jquery,Radio Button,请帮我解决这个问题:我如何在付款和交货类型之间建立关系(使用jquery)?例如,如果用户在自动选中的“收货时付款”中选择“预订单”,“预订单,交货不可用”。如果用户选择“PayPal”,他可以在“邮件服务”和“航空邮件”之间进行选择,但“预订单,不提供送货”是只读的。我感谢你的帮助 <label>Payment type:</label> <input type="radio" name="payment" value="10" class="payment-it

请帮我解决这个问题:我如何在付款和交货类型之间建立关系(使用jquery)?例如,如果用户在自动选中的“收货时付款”中选择“预订单”,“预订单,交货不可用”。如果用户选择“PayPal”,他可以在“邮件服务”和“航空邮件”之间进行选择,但“预订单,不提供送货”是只读的。我感谢你的帮助

<label>Payment type:</label>
<input type="radio" name="payment" value="10" class="payment-item" id="pay-type-10" onclick="shEvOrd('payment',this)"><label class="label" for="pay-type-10">Pre Order</label>
<input type="radio" name="payment" value="11" class="payment-item" id="pay-type-11" onclick="shEvOrd('payment',this)"><label class="label" for="pay-type-11">PayPal</label>
<br>
<label>Delivery type:</label>
<input type="radio" name="delivery" value="7" class="delivery-item" id="del-type-7" onclick="shEvOrd('delivery',this,1)"><label class="label" for="del-type-7">Pre Order, delivery not available</label>
<input type="radio" name="delivery" value="6" class="delivery-item" id="del-type-6" onclick="shEvOrd('delivery',this,1)"><label class="label" for="del-type-6">Mail Service</label>
<input type="radio" name="delivery" value="5" class="delivery-item" id="del-type-5" onclick="shEvOrd('delivery',this,1)"><label class="label" for="del-type-5">AIR MAIL</label>

<input type="button" value="Place order" id="order-button" onclick="shopCheckOut();this.order.reset">
付款类型:
预购
贝宝

交付类型: 预购,无法送货 邮件服务 航空邮件
您可以试试这个

// attach a click event to the payment radio group
$(".payment-item").click(function(){

    var payment = $("input:radio[name='payment']:checked").val(), // check the current value
        isPaypal = payment !== "10", // a simple check to see what was selected
        delivery = $("#del-type-7"); // get the radio element with the pre-order option           


    return delivery.prop({
        // Disabled if `isPaypal` is true
        disabled: isPaypal,
        // Checked if `isPaypal` is true
        checked: !isPaypal
    });      
});
请看演示

您所需要的一切:

var $delType7 = $("#del-type-7");       // Cache your elements
$("[name='payment']").click(function(){
    var PPal = $("[name='payment'][value='10']").is(':checked'); // Boolean
    $delType7.prop({checked:!PPal, disabled:PPal}); // boolean to toggle states
});
从HTML中删除
onclick