I have two inputs
of type radio
. Here is the code below:
<input type="radio" id="isgift0" name="isgift" value="0" class="arredondado" />
<label for="isgift0">Teste 1</label>
<input type="radio" id="isgift1" name="isgift" value="1" style="display: none;" />
<label for="isgift1">Teste 2</label>
And I have the following code in jQuery
:
$j('input[name=isgift]').click(function(){
if($j('#isgift1').is(':checked')){
$j(".gift-from").val(name_from);
$j(".gift-to").val(name_to);
$j(".mensagem-pedido").removeClass("divDisabled");
$j(".box-gift").addClass("divActive");
$j('#allow-gift-messages-for-order-container').show();
}
else if($j('#isgift0').is(':checked')){
$j(".gift-from").val('Anônimo');
$j(".gift-to").val(name_to);
$j(".box-gift").removeClass("divActive");
$j(".mensagem-pedido").addClass("divDisabled");
}
Since they are ìnputs
of type radio
and with the same names, you can only mark one of two. But I needed to do something more than I can not do. I wanted when the first ìnput
, in case with id=isgift0
, if it was checked and the user clicked on it, it was cleared. I wanted to do this just for this input.