0

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&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="8"><b>Camarão R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="7"><b>Salmão e Queijo Qualho R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="6"><b>Salmão R$ 6.00&nbsp;&nbsp;&nbsp;</b></label>
  <label class="textoPadrao pequeno laranja"><input type="radio" name="tamanho-324" value="10"><b>Mignom R$ 6.00&nbsp;&nbsp;&nbsp;</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

4
  • 3
    live is deprecated use on instead.. Commented Mar 6, 2013 at 11:35
  • Try $('input[name="tamanho-'+this.id+'"]:checked') (i.e., add double-quotes around the value of the name attribute). Commented Mar 6, 2013 at 11:37
  • The element <tamanho-324> doesn't exist. Your selector is wrong. Use input[name='tamanho-324'] instead Commented Mar 6, 2013 at 11:38
  • This has nothing to do with the jquery-validate plugin. Please be more careful when tagging. Thanks. Edited. Commented Mar 6, 2013 at 15:10

2 Answers 2

1

Try this use name selector in jquery.

var tamanho = $('input:radio[name="tamanho-324"]:checked').val();
Sign up to request clarification or add additional context in comments.

Comments

0
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);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.