Foros del Web » Programando para Internet » Javascript »

copiar valor de input text

Estas en el tema de copiar valor de input text en el foro de Javascript en Foros del Web. hola! quisier saber como puedo enviar el valor del input text a un value de un checkbox Cita: <tr id='clonable' style='display:none;' > <td><input name='nroId[]' style='text-transform:uppercase' ...
  #1 (permalink)  
Antiguo 15/09/2008, 23:44
 
Fecha de Ingreso: febrero-2008
Mensajes: 73
Antigüedad: 16 años, 2 meses
Puntos: 0
copiar valor de input text

hola!

quisier saber como puedo enviar el valor del input text a un value de un checkbox

Cita:
<tr id='clonable' style='display:none;' >
<td><input name='nroId[]' style='text-transform:uppercase' type='text' size='20' maxlength='12' onkeyup="mascara(this,'-',patron,false)"


onchange="document.getElementById('tact[]').value=this.value;"/>


</td>
<td><?echo $paises?></td>
<td align='center'>
<input name="tact[]" type="checkbox"/>
intento eso pero no me resulta

como ven trate de aplicar a traves del evento onchange pero no funka!
  #2 (permalink)  
Antiguo 16/09/2008, 01:13
Avatar de hector2c  
Fecha de Ingreso: noviembre-2007
Ubicación: Perú - Tacna
Mensajes: 979
Antigüedad: 16 años, 5 meses
Puntos: 25
Pregunta Respuesta: copiar valor de input text

puedes probar con el siguiente formulario...

Código HTML:
 <form name="formulario" id="formulario">
      <input name="texto" type="text" id="texto" onchange="this.form.cuadrado.value = this.form.texto.value;" />
      <input name="cuadrado" type="checkbox" id="cuadrado" value="" />
      <input type="button" onclick="javascript: alert(this.form.cuadrado.value);" value="Mostrar" />
    </form> 
suerte amigo !
__________________
blog: hector2c.wordpress.com
email: [email protected]
  #3 (permalink)  
Antiguo 16/09/2008, 10:42
 
Fecha de Ingreso: febrero-2008
Mensajes: 73
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: copiar valor de input text

Cita:
Iniciado por hector2c Ver Mensaje
puedes probar con el siguiente formulario...

Código HTML:
 <form name="formulario" id="formulario">
      <input name="texto" type="text" id="texto" onchange="this.form.cuadrado.value = this.form.texto.value;" />
      <input name="cuadrado" type="checkbox" id="cuadrado" value="" />
      <input type="button" onclick="javascript: alert(this.form.cuadrado.value);" value="Mostrar" />
    </form> 
suerte amigo !
pero como lo hago si la tabla se genera dinamicamente y los checkbox los declare como arreglo (fijate en el name)
entonces como lo hago porque no ocupo id????

Código:
<script>
function agregaFila( id ) {
   var tabla = document.getElementById( id );
   var tbody = document.getElementById( tabla.id ).tBodies[0];
   var row = tbody.rows[0].cloneNode( true );
   var id = 1;
   while( document.getElementById( tabla.id+'_fila_'+id ) ) {
      id++;
   }
   row.id = tabla.id+'_fila_'+id;
   row.style.display = '';
   tbody.appendChild( row );
}

function borraFila( fila ) {
   var id = fila.id;
   if( fila.parentNode.rows.length <= 2 ) return;
   document.getElementById( id ).parentNode.removeChild( document.getElementById(id) );
}
</script>

<div id='content'>
  <div id='right'>
    <? 
$op = $_GET[op] ;

if ( $op == 1 ){ 

	$paises=paises();
    $documento=documentos();
    $tipo_registro=tipo_registro(); 
	?>
    <h2>Formulario de Registro Ingreso/Egreso</h2>
    <br/>
    <br/>
    <form action='procesa_formulario.php' method='post' name='doc'>
      <table width='40%' border='0' cellspacing='1'>
        <!--DWLayoutTable-->
        <tr>
          <td width='140' height='21' >Transportista</td>
          <td width='238'><input type='text' size='30' name="transportista" style="text-transform:capitalize"/></td>
        </tr>
        <tr>
          <td height='24'>Veh&iacute;culo</td>
          <td width='238'><input type='text' size='15' name="vehiculo" style="text-transform:uppercase" /></td>
        </tr>
        <tr>
          <td height='24'>Tipo Registro</td>
          <td width='238'><? echo $tipo_registro;?></td>
        </tr>
      </table>
      <br/>
      <hr />
      <table id='tabla_1' width='383' border='0' cellspacing='1'>
        <thead>
          <tr>
            <th width='133' align='left'>Documento<br/></th>
            <th width='131' align='left'>Folio</th>
            <td width='112'>&nbsp;</td>
          </tr>
        </thead>
        <tr id='clonable' style='display:none'  >
          <td><?echo $documento; ?></td>
          <td><input type='text' name='folio[]' size='20' /></td>
          <td><a href='#' onclick='borraFila(this.parentNode.parentNode)' >Borrar</a></td>
        </tr>
        <tr id='tabla_1_fila_1'>
          <td><?echo $documento;?></td>
          <td><input type='text' name='folio[]' size='20' /></td>
          <td><a href='#' onclick='borraFila(this.parentNode.parentNode)'>Borrar</a></td>
        </tr>
        <tfoot>
        </tfoot>
      </table>
      <input type='button' value='Agregar Documento' onclick="javascript:agregaFila( 'tabla_1' );">
      <hr />
      <table id='tabla_2' width='502' border='0' cellspacing='1'>
        <thead>
          <tr>
            <th width='150' align='left'>Contenedor Nro.Id</th>
            <th width='149' align='left'>Procedencia</th>
            <th width='55' align='center'>T.A.C.T</th>
            <td width='135'>&nbsp;</td>
          </tr>
        </thead>
        <tr id='clonable' style='display:none;'  >
          <td><input name='nroId[]' style='text-transform:uppercase' id= "texto" type='text' size='20' maxlength='12' onkeyup="mascara(this,'-',patron,false)"/></td>
          <td><?echo $paises?></td>
          <td align='center'>
	 	    <input name="tact[]" type="checkbox"/>
          
          <td><a href='#' onclick='borraFila(this.parentNode.parentNode)'>Borrar</a></td>
        </tr>
        <tr id='tabla_2_fila_1'>
                   <td><input name='nroId[]' style='text-transform:uppercase' id= "texto" type='text' size='20' maxlength='12' onkeyup="mascara(this,'-',patron,false)"</td>
          <td><?echo $paises?></td>
          <td align='center'>
		 	 <input name="tact[]" type="checkbox"/>
            
			</td>
          <td><a href='#' onclick='borraFila(this.parentNode.parentNode)'>Borrar</a></td>
        </tr>
        <tfoot>
        </tfoot>
      </table>
      <input type='button' value='Agregar Contenedor' onclick="javascript:agregaFila( 'tabla_2' );">
      <hr />
      <br />
      <input name='enviar' type='submit' value='Enviar Formulario' />
    </form>
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 19:13.