Foros del Web » Programando para Internet » Javascript »

checkbox con textarea

Estas en el tema de checkbox con textarea en el foro de Javascript en Foros del Web. al presionar un checkbox se carga el estado del checked al textarea, como se puede hacer ? @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript : Ver original < ...
  #1 (permalink)  
Antiguo 08/06/2010, 14:44
 
Fecha de Ingreso: marzo-2010
Mensajes: 432
Antigüedad: 14 años, 1 mes
Puntos: 11
checkbox con textarea

al presionar un checkbox se carga el estado del checked al textarea, como se puede hacer ?



Código Javascript:
Ver original
  1. <script>
  2.  
  3.  
  4. </script>
  5.  
  6.  
  7. <textarea name="textarea" cols="55"></textarea>
  8. <br><br>
  9. <input type="checkbox" name="checkbox1" value="checkbox">opcion 1<br>
  10. <input type="checkbox" name="checkbox2" value="checkbox">opcion 2<br>
  11. <input type="checkbox" name="checkbox3" value="checkbox">opcion 3<br>
  12. <input type="checkbox" name="checkbox4" value="checkbox">opcion 4<br>

Última edición por tazzwt; 08/06/2010 a las 14:52
  #2 (permalink)  
Antiguo 08/06/2010, 14:55
Avatar de _cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 10 meses
Puntos: 310
Respuesta: checkbox con textarea

Creo que se puede así:
Código Javascript:
Ver original
  1. function textarea(){
  2.  var c1 = document.getElementById('c1');
  3.  var c2 = document.getElementById('c2');
  4.  var c3 = document.getElementById('c3');
  5.  var c4 = document.getElementById('c4');
  6.  var texto = document.getElementById('texto');
  7.  if(c1.checked==true){
  8.   var a1 = 'true'
  9.  }else{
  10.   a1= 'false'
  11.  }
  12.  if(c2.checked==true){
  13.   var a2 = 'true'
  14.  }else{
  15.   a2= 'false'
  16.  }
  17.  if(c3.checked==true){
  18.   var a3 = 'true'
  19.  }else{
  20.   a3= 'false'
  21.  }
  22.  if(c4.checked==true){
  23.   var a4 = 'true'
  24.  }else{
  25.   a4= 'false'
  26.  }
  27.  texto.value= a1+'**'+a2+'**'+a3+'**'+a4;
  28. }

Código HTML:
Ver original
  1. <form id='miForm' action='' method='post'>
  2. <textares id='texto' cols='10' rows='3'></textarea>
  3. <input type='checkbox' id='c1' onclick='textarea();' />
  4. <input type='checkbox' id='c2' onclick='textarea();' />
  5. <input type='checkbox' id='c3' onclick='textarea();' />
  6. <input type='checkbox' id='c4' onclick='textarea();' />

Saludos (:
  #3 (permalink)  
Antiguo 08/06/2010, 15:38
Avatar de Most  
Fecha de Ingreso: marzo-2009
Mensajes: 642
Antigüedad: 15 años, 1 mes
Puntos: 6
Respuesta: checkbox con textarea

perdonen me e equibocado de tema :-|

Etiquetas: checkbox, textarea
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:52.