Ver Mensaje Individual
  #7 (permalink)  
Antiguo 01/04/2010, 11:33
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: select multiple a textarea

Hola

Prueba con esto

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var control = 0;
  5. function muestraentextarea(correo) {
  6. var txtarea = document.getElementById("envia_emails");
  7. cantidad_emails = txtarea.value.split(",");
  8.  
  9.     if (cantidad_emails.length <= 3) {
  10.         if (control == 0) {
  11.             txtarea.value += correo;
  12.         } else if (control <= 3) {
  13.             txtarea.value += "," + correo;
  14.         }
  15.     }
  16.  
  17. control += 1;
  18. //alert(cantidad_emails.length);
  19. }
  20.  
  21. var total = 0;
  22. var valor_max = 0;
  23. function valcantidad(txtarea) {
  24. cantidad_emails = txtarea.value.split(",");
  25. total = txtarea.value.length;
  26.     if (cantidad_emails.length <= 4) {
  27. valor_max = 0;
  28.         for (i = 0; i < cantidad_emails.length; i++) {
  29.         valor_max += cantidad_emails[i].length;
  30.         }
  31.  
  32.         if(total > parseInt(valor_max+3)) {
  33.         txtarea.value = txtarea.value.substring(0,parseInt(valor_max+3));
  34.         }
  35.     } else {
  36.         txtarea.value = txtarea.value.substring(0,total-1);
  37.     }
  38. }
  39. </script>
  40. </head>
  41. <body>
  42. <form name="forms">
  43. <select multiple="multiple" size="7" name="correos" id="correos" style="width: 500px;" onchange="muestraentextarea(this.options[this.selectedIndex].value)">
  44. <option value="[email protected]">[email protected]</option>
  45. <option value="[email protected]">[email protected]</option>
  46. <option value="[email protected]">[email protected]</option>
  47. <option value="[email protected]">[email protected]</option>
  48. <option value="[email protected]">[email protected]</option>
  49. <option value="[email protected]">[email protected]</option>
  50. <option value="[email protected]">[email protected]</option>
  51. <option value="[email protected]">[email protected]</option>
  52. </select>
  53. <br /><br />
  54. <textarea name="envia_emails" id="envia_emails" style="width: 500px;" rows="5" onkeyup="valcantidad(this);"></textarea>
  55. </form>
  56. </body>
  57. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />