Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/09/2008, 10:42
shembao
 
Fecha de Ingreso: febrero-2008
Mensajes: 73
Antigüedad: 17 años
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>