Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/01/2013, 08:51
Avatar de JeMaGa
JeMaGa
 
Fecha de Ingreso: julio-2011
Ubicación: Bogota
Mensajes: 430
Antigüedad: 13 años, 7 meses
Puntos: 4
Id varias tablas

bUENOS DIAS NECESITO UN FAVOR, TENGO UNA INQUIETUD, RESULTA QUE NECESITO INSERTAR CAMPOS DINAMICOS, PERO EN LOS CAMPOS NECESITO CREAR TABLAS, PERO NO SE COMO HACER PARA QUE SE PUEDAN INSERTAR TABLAS DINAMICAMENTE.

YO TENGO LO SIGUIENTE

UN BOTON ME INSERTA VARIOS CAMPOS, Y OTRO BOTON ME CREA TABLAS PERO CON UN SOLO NOMBRE.

LISTO EN LAS TABLAS SE MUESTRAN UNAS LISTAS DESPLEGABLES QUE TAMBIEN SON DINAMICAS, PERO ESTAS TABLAS CON ESTAS LISTAS SOLO ME APARECEN EN UN CAMPO ES DECIR EJEMPLO

INSERTO 2 FILAS DE CAMPOS Y QUIERO INSERTAR EN CADA FILA UNA TABLA , ENTONCES LE DOY EN OTRO BOTON Y ME INSERTA LA TABLA PERO SOLO EN LA PRIMERA FILA, Y NECESITARIA UNA POR FILA

ESTO ES LO QUE TENGO DE CODIGO!!

ESTA ES LA FUNCION QUE ME CREA LOS CAMPOS DINAMICOS

Código Javascript:
Ver original
  1. var posicionCampo=1;
  2.     var posicionCampoMedio=1;
  3.     var posicionCampoLote=1;
  4.    
  5.  
  6.     function agregarUsuario(){
  7.  
  8.     nuevaFila = document.getElementById("tabla").insertRow(-1);
  9.  
  10.     nuevaFila.id=posicionCampo;
  11.  
  12.       nuevaCelda=nuevaFila.insertCell(-1);
  13.     nuevaCelda.innerHTML="<td><input type='text' size='12' name='Anali["+posicionCampo+"]' ></td>";
  14.  
  15.     nuevaCelda=nuevaFila.insertCell(-1);
  16.     nuevaCelda.innerHTML="<td> <input type='text' size='30' id='Produc"+posicionCampo+"' name='Produc["+posicionCampo+"]' onkeypress='return soloLetras(event)'></td>";
  17.  
  18.     nuevaCelda=nuevaFila.insertCell(-1);
  19.     nuevaCelda.innerHTML="<td> <input type='text' size='9' id='Lot"+posicionCampo+"' name='Lot["+posicionCampo+"]' value='' onkeypress='return soloLetras(event)'></td>";
  20.  
  21.     nuevaCelda=nuevaFila.insertCell(-1);
  22.     nuevaCelda.innerHTML="<td> <input type='text' size='15' id='Presen"+posicionCampo+"' name='Presen["+posicionCampo+"]'  ></td>";
  23.  
  24.     nuevaCelda=nuevaFila.insertCell(-1);
  25.     nuevaCelda.innerHTML="<td> <input type='text' size='20' id='Clien"+posicionCampo+"' name='Clien["+posicionCampo+"]' value=''></td>";
  26.  
  27.     nuevaCelda=nuevaFila.insertCell(-1);
  28.     nuevaCelda.innerHTML="<td> <input type='text' size='8' name='Canti["+posicionCampo+"]' value=''></td>";
  29.  
  30.     nuevaCelda=nuevaFila.insertCell(-1);
  31.     nuevaCelda.innerHTML="<td> <input type='text' size='20' id='For"+posicionCampo+"' name='For["+posicionCampo+"]' value=''></td>";
  32.  
  33.     nuevaCelda=nuevaFila.insertCell(-1);
  34.     nuevaCelda.innerHTML="<td> <input size='10' id='fc_1348595831' type='text' name='FechaRec["+posicionCampo+"]' title='YYMMDD' onClick='displayCalendar(this);'></td>";
  35.  
  36.     nuevaCelda=nuevaFila.insertCell(-1);
  37.     nuevaCelda.innerHTML="<td> <input size='10' id='fc_1348596085' type='text' name='FechaAn["+posicionCampo+"]' title='YYMMDD' onClick='displayCalendar(this);'></td>";
  38.  
  39.     nuevaCelda=nuevaFila.insertCell(-1);
  40.     nuevaCelda.innerHTML="<td><input size='10' id='fc_1348596150' type='text' name='FechaRes["+posicionCampo+"]' title='YYMMDD' onClick='displayCalendar(this);'></td>";
  41.  
  42.     nuevaCelda=nuevaFila.insertCell(-1);
  43.     nuevaCelda.innerHTML="<td><table name='medios["+posicionCampo+"]' id='medios"+posicionCampo+"'></table></td>";
  44.    
  45.     nuevaCelda=nuevaFila.insertCell(-1);
  46.     nuevaCelda.innerHTML="<td><table name='lote["+posicionCampo+"]' id='lote'></table></td>";
  47.  
  48.     nuevaCelda=nuevaFila.insertCell(-1);
  49.     nuevaCelda.innerHTML="<td> <input type='text' size='8' id='Tec"+posicionCampo+"' name='Tec["+posicionCampo+"]' value='USP 35'></td>";
  50.    
  51.     nuevaCelda=nuevaFila.insertCell(-1);
  52.     nuevaCelda.innerHTML="<td> <input type='text' size='18' id='Meto"+posicionCampo+"' name='Meto["+posicionCampo+"]' value=''></td>";
  53.  
  54.     nuevaCelda=nuevaFila.insertCell(-1);
  55.     nuevaCelda.innerHTML="<td> <input type='text' size='18' id='Formato"+posicionCampo+"' name='Formato["+posicionCampo+"]' value=''></td>";
  56.  
  57.     nuevaCelda=nuevaFila.insertCell(-1);
  58.     nuevaCelda.innerHTML="<td><input type='button' value='Eliminar' onclick='eliminarUsuario(this)'></td>";
  59.  
  60.     posicionCampo++;
  61.  
  62.     }

ESTA ES LA FUNCION QUE ME CREA LAS TABLAS DENTRO DE LOS CAMPOS

Código Javascript:
Ver original
  1. function agregarmedios(){
  2.        
  3.     nuevaCampo = document.getElementById('medios"+posicionCampo+"').insertRow(-1); 
  4.     nuevaCampo2 = document.getElementById('lote').insertRow(-1);   
  5.     nuevaCampo.id=posicionCampoMedio;
  6.     nuevaCampo2.id=posicionCampoLote;
  7.    
  8.     nuevalista=nuevaCampo.insertCell(-1);
  9.     nuevalista.innerHTML="<td><select name='nombre["+posicionCampoMedio+"]'><option value='0'>Medios</option><option value='AGAR CASOY (Mesofilos aerobios)'>AGAR CASOY (Mesofilos aerobios)</option><option value='AGAR CETRIMIDE (Pseudomonas sp)'>AGAR CETRIMIDE (Pseudomonas aeruginosa)</option><option value='AGAR CHROMOCULT (Coliformes totales)'>AGAR CHROMOCULT (Coliformes totales)</option><option value='AGAR COLUMBIA (Clostridum sporogenes)'>AGAR COLUMBIA (Clostridum sporogenes)</option><option value='AGAR MacConkey (E. coli)'>AGAR MacConkey (E. coli)</option><option value='AGAR PLATE COUNT (Mesofilos aerobios)'>AGAR PLATE COUNT (Mesofilos aerobios)</option><option value='AGAR SABOURAUD (Candida albicans)'>AGAR SABOURAUD (Candida albicans)</option><option value='AGAR SABOURAUD (Hongos y levaduras)'>AGAR SABOURAUD (Hongos y levaduras)</option><option value='AGAR SALADO MANITOL (Staphylococcus aureus)'>AGAR SALADO MANITOL (Staphylococcus aureus)</option><option value='AGAR VRB (Coliformes)'>AGAR VRB (Coliformes)</option><option value='AGAR VRB (Enterobacterias)'>AGAR VRB (Enterobacterias)</option><option value='AGAR XLD (Salmonella sp)'>AGAR XLD (Salmonella sp)</option><option value='CALDO BRILLA 2 % (Coliformes fecales)'>CALDO BRILLA 2 % (Coliformes fecales)</option><option value='CALDO BRILLA 2 % (Coliformes totales)'>CALDO BRILLA 2 % (Coliformes totales)</option></select></td>";
  10.    
  11.     nuevalista=nuevaCampo.insertCell(-1);
  12.     nuevalista.innerHTML="<td><input type='button' value='x' onclick='eliminarcampo(this)'></td>";
  13.    
  14.     nuevalote=nuevaCampo2.insertCell(-1);
  15.     nuevalote.innerHTML="<td><input type='text'  size='8' name='lotes"+posicionCampoLote+"' id='lotes["+posicionCampoLote+"]' value=''></td>";
  16.        
  17.     nuevalote=nuevaCampo2.insertCell(-1);
  18.     nuevalote.innerHTML="<td><input type='button' value='x' onclick='eliminarcampo(this)'></td>";      
  19.        
  20.         posicionCampoMedio++;
  21.         posicionCampoLote++;
  22.         }

Y ESTO ES LO DEL FORMULARIO

Código PHP:
Ver original
  1. <form id="form1" name="form1" method="post" action="operaciones.php">
  2.  
  3. <input name="Agregar" type="button" value="Filas" onClick="agregarUsuario()">
  4. <input name="AgregarMedios" type="button" value="Medios" onClick="agregarmedios()">
  5.  
  6.   <table width="236%" border="1" id="tabla">
  7.     <tr>
  8.       <th width="7%" scope="col">No.Analisis</th>
  9.       <th width="7%" scope="col">Producto</th>
  10.       <th width="7%" scope="col">Lote</th>
  11.       <th width="7%" scope="col">Presentacion</th>
  12.       <th width="7%" scope="col">Cliente</th>
  13.       <th width="7%" scope="col">Cantidad Muestreada</th>
  14.       <th width="7%" scope="col">Forma Farmaceutica</th>
  15.       <th width="7%" scope="col"><p>Fecha Recepcion</p></th>
  16.       <th width="7%" scope="col"><p>Fecha Analisis</p></th>
  17.       <th width="7%" scope="col"><p>Fecha Resultados</p></th>
  18.       <th width="12%" scope="col">Medios Cultivo</th>
  19.       <th width="7%" scope="col">N.Lote Medios </th>
  20.       <th width="3%" scope="col">Tecnica</th>
  21.       <th width="3%" scope="col">Metodo</th>
  22.       <th width="3%" scope="col">Formato</th>
  23.     </tr>
  24.    
  25.   </table></br>
  26.   <input name="enviar" type="submit" value="ENVIAR" />

GRACIAS POR TODA LA AYUDA QUE ME PUEDAN BRINDAR