Ver Mensaje Individual
  #12 (permalink)  
Antiguo 23/04/2012, 21:20
Avatar de Nemutagk
Nemutagk
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: México
Mensajes: 2.633
Antigüedad: 20 años, 1 mes
Puntos: 406
Respuesta: Envio de correo a varios destinatarios con phpMailer

mmm primero verifica que versión de JQuery es la que usas, el código que yo deje es para la versión 1.7 para arriba, si usas una versión anterior no funcionará

Código PHP:
Ver original
  1. <?php
  2. if (isset($_POST['opciones'])) {
  3.     echo '<pre>';
  4.     var_dump($_POST['opciones']);
  5.     echo '</pre>';
  6. }else {
  7. ?>
  8. <html>
  9.     <head>
  10.         <title>checkbox 2</title>
  11.         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  12.         <script type="text/javascript">
  13.             $(document).on('ready',function() {
  14.                 $('#chk_todos').on('click', function() {
  15.                     $('input[type=checkbox]').each(function() {
  16.                         if ($(this).attr('checked') != 'checked') {
  17.                             $(this).attr('checked','checked');
  18.                         }else {
  19.                             $(this).removeAttr('checked');
  20.                         }
  21.                     });
  22.                 });
  23.                
  24.                 $('#enviar').on('click',function() {
  25.                     var arrayOpt = new Array;
  26.                     $('input[type=checkbox]').each(function() {
  27.                         if ($(this).attr('checked') == 'checked') {
  28.                             arrayOpt.push($(this).val());
  29.                         }
  30.                     });
  31.                    
  32.                     $.ajax({
  33.                         url:'http://localhost/demos/checkbox.php',
  34.                         type:'post',
  35.                         data: 'opciones='+arrayOpt,
  36.                         success: function(datos) {
  37.                             $('#respuesta').html(datos);
  38.                         }
  39.                     });
  40.                    
  41.                     return false;
  42.                 });
  43.             });
  44.         </script>
  45.     </head>
  46.     <body>
  47.         <form id="form1" method="post"  style="width: 50%;" name="form1">
  48.         <fieldset><label for="nombre">Nombre</label> <input type="text" name="nombre" id="nombre" class="text ui-widget-content ui-corner-all" />
  49.         <table border="0" id="users">
  50.         <tr>
  51.         <td width="244"><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" />
  52.         Oscar Montes
  53.         </label></td>
  54.  
  55.         </tr>
  56.         <tr>
  57.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Oscar Montes</label></td>
  58.         </tr>
  59.         <tr>
  60.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Diana Garcia</label></td>
  61.         </tr>
  62.         <tr>
  63.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Lucero Garcia</label></td>
  64.         </tr>
  65.         <tr>
  66.  
  67.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 5</label></td>
  68.         </tr>
  69.         <tr>
  70.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 6</label></td>
  71.         </tr>
  72.         <tr>
  73.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 7</label></td>
  74.         </tr>
  75.         <tr>
  76.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 8</label></td>
  77.  
  78.         </tr>
  79.         <tr>
  80.         <td><label><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 9</label></td>
  81.         </tr>
  82.         <tr>
  83.         <td><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 10</td>
  84.         </tr>
  85.         <tr>
  86.         <td><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 11</td>
  87.         </tr>
  88.         <tr>
  89.  
  90.         <td><input class="chk" type="checkbox" name="opcion[]" value="[email protected]" /> Destinatario 12</td>
  91.         </tr>
  92.         <tr>
  93.         <td>&nbsp;</td>
  94.         </tr>
  95.         <tr>
  96.         <td><label><input name="marcar" type='checkbox' id='chk_todos' value="checkbox" />
  97.         </label> todos</td>
  98.         </tr>
  99.         </table>
  100.         </fieldset>
  101.         <p>
  102.         <input name="contador" id="contador" type="text" value="ninguno" />
  103.         </p>
  104.         <p>
  105.         <label>
  106.         <input type="submit" id="enviar" name="Submit" value="Enviar" />
  107.         </label>
  108.         </p>
  109.         </form>
  110.         <div id="respuesta"></div>
  111.     </body>
  112. </html>
  113. <?php } ?>
__________________
Listo?, tendría que tener 60 puntos menos de IQ para considerarme listo!!!
-- Sheldon Cooper
http://twitter.com/nemutagk
PD: No contestaré temas vía mensaje personal =)