Reputation: 717
I have this HTML:
<div class="produtoListaDescTamanho">
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="9"><b>Frango Teriaky R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="8"><b>Camarão R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="7"><b>Salmão e Queijo Qualho R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="6"><b>Salmão R$ 6.00 </b></label>
<label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="10"><b>Mignom R$ 6.00 </b></label><br><br>
</div>
and this Jquery not working for validate is input radio with Jquery, var tamanho = undefined. Jquery code:
$(document).ready(function(){$('.produtoAddCarinho').live("click",(function(){
alert(this.id);
var tamanho = $('tamanho-324:checked').val(); // or $('input[name=tamanho-'+this.id+']:checked', '#tabela_geral').val();
var produto = document.getElementById('desc-'+this.id).innerHTML;
if (tamanho == undefined)
{
$().toastmessage('showErrorToast', "Selecione o tamanho, para adiconar o produto <br><br>" + produto );
}
else
{
Inserir(this.id, tamanho, produto);
};
temp = document.getElementsByName('tamanho-'+this.id);
$(temp ).removeAttr('checked');
$(temp ).attr('previousValue', false);
}))});
tks
Upvotes: 0
Views: 1201
Reputation: 46
repalce
temp = document.getElementsByName('tamanho-'+this.id);
$(temp ).removeAttr('checked');
$(temp ).attr('previousValue', false);
with
$('#tamanho-'+this.id ).each(function( index ) {
this.removeAttr('checked');
this.attr('previousValue', false);
});
Upvotes: 0
Reputation: 6736
Try this use name selector in jquery.
var tamanho = $('input:radio[name="tamanho-324"]:checked').val();
Upvotes: 1