Visualizzazione dei risultati da 1 a 3 su 3

Visualizzazione discussione

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 1999
    Messaggi
    22

    Due checkbox- come renderli indipendenti ?

    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>&nbsp; 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>&nbsp; piccante</label>
     
     </div>
          
    </body>
    </html>
    Ultima modifica di Mistik; 04-09-2015 a 09:49

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.