Ho creato questo script, ma quando clicco sul primo checkbox mi cambia anche il valore del secondo pur non essendo cekkato.
Vorrei, o renderli indipendenti, oppure con un checked ottenere il check di tutti i check nella pagina.
Mi aiutate a trovare una soluzione ?
codice:<!DOCTYPE html> <!--[if IE 8]> <html lang="it" class="ie8"> <![endif]--> <!--[if IE 9]> <html lang="it" class="ie9"> <![endif]--> <!--[if !IE]><!--> <html lang="en"> <!--<![endif]--> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(document).ready(function () { $('#txt').val($(this).is(':checked')); $('#txt').val('€ 45,00 /mese'); $('input[type=checkbox]').click(function(){ if ($('input[type=checkbox]').is(':checked')) { $('#txt').val('€ 53,54 /mese'); } else{ $('#txt').val('€ 45,00 /mese'); } }); }); </script> <script> $(document).ready(function () { $('#txt2').val($(this).is(':checked')); $('#txt2').val('€ 10,00 /mese'); $('input[type=checkbox]').click(function(){ if ($('input[type=checkbox]').is(':checked')('#txt2')) { $('#txt2').val('€ 18,54 /mese'); } else{ $('#txt2').val('€ 10,00 /mese'); } }); }); </script> </head> <body> <!------- Primo checkbox -------------> <div> <h2 style="font-size:16px;"><strong>Pizza Light</strong></h2> <h1><strong> <input id="txt" type="text" value="txt"> </strong></h1> <input type="checkbox" id="txt" name="txt" value="piccante"><label> piccante</label> </div> <hr> <!------- Secondo checkbox -------------> <div> <h2 style="font-size:16px;"><strong>Pizza Style</strong></h2> <h1><strong> <input id="txt2" type="text" value="txt2"> </strong></h1> <input type="checkbox" id="txt2" name="txt2" value="piccante"><label> piccante</label> </div> </body> </html>

Rispondi quotando
