0

我只想在选择比萨饼后启用浇头 我想禁用浇头或在选择比萨饼之前出现。

<legend>Choose the pizza wrap type ?</legend>
<div class="control-group">//radio group
<label class="radio">
<input type="radio" name="pizza" id="pizza3"value="3" {% if pizza.rel == 3%}
 checked {% endif %}>
 Vegan
</label><br>
<label class="radio">
<input type="radio" name="pizza" id="pizza2" value="2" {% if pizza.rel == 2 %} 
 checked {% endif %}>
 Vegetarian
</label><br>
<label class="radio">
<input type="radio" name="pizza" id="pizza1" value="1" {% if 
pizza.rel == 1 %} checked {% endif %}>
Non vegetarian
</label><br>
<label class="radio">
<input type="radio" name="pizza" id="pizza0" value="0" {% if 
 pizza.rel == 0 %} checked {% endif %}>
 Halal meat
</label>
<button type="button" class="btn btn-link" id="pizza" onclick="captureSelection()">   
</button>
</div>

<h5>Toppings?</h5>
<div class="control-group">     
<label class="radio">
<input type="radio" name="topping" id="topping3" value="3" {% if topping.top == 3
%} checked {% endif %}>
Vegan 
</label><br>
<label class="radio">
<input type="radio" name="topping" id="topping2" value="2" {% if topping.top == 2 
%} checked {% endif %}>
Veggie
</label><br>
<label class="radio">
<input type="radio" name="topping" id="topping1" value="1" {% if topping.top == 1
%} checked {% endif %}>
Meat
</label><br>
<label class="radio">
<input type="radio" name="topping" id="topping0" value="0" {% if topping.top == 0 
%} checked {% endif %}>
Halal meat
</label>
<button type="button" class="btn btn-link" id="topping" onclick="captureSelection()">  
</button>
</div>

我用来检查单选按钮是否被选中的函数我应该执行 for 循环来检查是否从比萨饼中检查了单选按钮之一?

function captureSelection(){ 
    var u = document.getElementById('relevance');
    var t = document.getElementById ('topic');
    if (u.value=='unchecked' && u.value ==''){
        t.disable='true';
    }
    else (u.value=='checked'){
        t.enable='true';
    }
}
4

1 回答 1

2

您可以尝试以下方法:DEMO FIDDLE

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type= "text/javascript">
$(document).ready(function () {
    $(".a").click(function () {
        $(".b").prop('checked', false);
    });
    $(".b").click(function () {
        $(".a").prop('checked', false);
    });
});
</script>

注意:我已在您的输入类型收音机中添加了类。

于 2013-09-30T03:55:15.807 回答