Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/08/2014, 10:38
Avatar de Fernarey1810
Fernarey1810
 
Fecha de Ingreso: noviembre-2008
Mensajes: 214
Antigüedad: 15 años, 5 meses
Puntos: 1
Problema checkbox repite mensaje box

Probar el siguiente código por favor. Al tildar el CHECKBOX y confirmar con ACEPTAR se elimina el cliente. Todo funciona bien, pero si yo doy en cancelar, y luego vuelvo a intentar eliminar el cliente con el CHECBOX miren lo que ocurre. Se empieza a repetir 2 veces el mensaje localhost, luego se repite 3, luego 4, luego 5 etc porque ocurre eso?

Código HTML:
Ver original
  1. <title>Documento sin título</title>
  2. <script type='text/javascript' src='jquery-1.7.2.min.js'></script>
  3. <script type="application/javascript">
  4. function chk_click(id, check) {
  5.     $('input[name=baja]').live("click",function(){
  6.         var id = $(this).attr('id');
  7.        
  8.         var box = confirm("¿Está seguro que desea eliminar el cliente?");
  9.         if (box == true) {
  10.             $.ajax({
  11.                 type:'POST',
  12.                 url:'ajax_chk_cliente.php',
  13.                 data:'id= ' + id,
  14.                 success: function() {
  15.                     window.location.href = "ver_cliente.php";  // = 'ver_cliente.php'; //href
  16.                 }                                                                          
  17.             });
  18.         }else {
  19.             document.getElementById(id).checked = false;
  20.         }                                                                  
  21.     });
  22. }  
  23. </head>
  24.  
  25.  
  26. <form action="" method="post">
  27.     <input type="checkbox" id="1" name="baja" onclick="chk_click('1', 'check');" title="eliminar cliente" />';
  28.     <input type="checkbox" id="2" name="baja" onclick="chk_click('2', 'check');" title="eliminar cliente" />';
  29.     <input type="checkbox" id="3" name="baja" onclick="chk_click('3', 'check');" title="eliminar cliente" />';
  30. </form>
  31.  
  32. </body>
  33. </html>