Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/05/2013, 15:24
elsabio
 
Fecha de Ingreso: marzo-2003
Ubicación: Av. Grau 1190
Mensajes: 122
Antigüedad: 21 años, 2 meses
Puntos: 3
Respuesta: Recorrer checkbox y copiar a imput

Estimado Caricatos:

Gracias por tu respuesta. Estuve revisando tu sugerencia y llegue q este punto.-
================
<script type="text/javascript">
function copiar(){
var elementos = document.getElementsByName("opcion1");
texto = "";
for (x=0;x<elementos.length;x++){
texto = texto + elementos[x].value + ", "; }

document.forms['miformulario']['destinook'].value = texto

}
</script>

<form id="miformulario" action="#">
<input type="checkbox" name="opcion1" value="1" id="opcion1" onClick="copiar()">
<input type="checkbox" name="opcion1" value="2" id="opcion2" onClick="copiar()">
<input type="checkbox" name="opcion1" value="3" id="opcion3" onClick="copiar()">
<input type="checkbox" name="opcion1" value="4" id="opcion4" onClick="copiar()">

<input type="text" name="destinook" />

</form>

============

Cuando selecciono un check recorre todo; solo necesito que se copie los que selecciono y se copie en el input separado por una (,). Ademas si deselecciono un check tambien se quita del input.

A ver si me puene ayudar.

saludos