 |
| 07/11/2007 16:46 |
 |

Registrado: 07/11/2007
Nº mensajes: 5
 |
|
 |
| |
leo_25 |

|
|
 |
| |
muchas gracias Living. mira tengo el siguiente escript hice las correcciones para eliminar todo va de maravillas.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Ejemplo formulario</title> <script language="javascript" type="text/javascript"> var indiceFilaFormulario=1; function addPerson(id){ myNewRow = document.getElementById(id).insertRow(-1); myNewRow.id=indiceFilaFormulario; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input style='width: 25px;'type='text' disabled='disabled' id='item["+indiceFilaFormulario+"]' name='item["+indiceFilaFormulario+"]' /></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td> <input style='width: 20px;' type='text' disabled id='alt["+indiceFilaFormulario+"]' name='alt["+indiceFilaFormulario+"]' /></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input style='width: 20px;' type='text' id='cant["+indiceFilaFormulario+"]' name='cant["+indiceFilaFormulario+"]'/></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input style='width: 25px;' type='text' id='unid["+indiceFilaFormulario+"]'name='unid["+indiceFilaFormulario+"]'/></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><textarea rows='1' cols='20'name='descripcion["+indiceFilaFormulario+"]' name='descripcion["+indiceFilaFormulario+"]' />"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input style='width: 80px;' type='text' id='marca["+indiceFilaFormulario+"]' name='marca["+indiceFilaFormulario+"]'></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input style='width: 50px;' type='text' id='prec_unit["+indiceFilaFormulario+"]' name='prec_unit["+indiceFilaFormulario+"]'></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input style='width: 50px;' type='text' disabled id='costototal["+indiceFilaFormulario+"]' name='costototal["+indiceFilaFormulario+"]'></td>"; myNewCell=myNewRow.insertCell(-1); myNewCell.innerHTML="<td><input type='button' value='Quitar' onclick='removePerson(this)'></td>"; indiceFilaFormulario++; } function totalItem(total,cantidad,pre_unit) { document.getElementById(total).value=cantidad*document.getElementById(pre_unit).value } function removePerson(obj){ var oTr = obj; while(oTr.nodeName.toLowerCase()!='tr'){ oTr=oTr.parentNode; } var root = oTr.parentNode; root.removeChild(oTr); } </script> </head> <body>
<form name="formulario" action="pruebainput.php" method="POST"> <table cellpadding='2' cellspacing='2' > <!-- <tr> <td align="center"> </td> </tr>--> <!-- <tr> <td>--><table cellpadding='3' cellspacing='3' id="tabla"> <tr style='background-color:#C5E3EE;font-size:10px;text-align:center;'> <th>Item</th> <th>Alt.</th> <th>Cant</th> <th>Unid</th> <th>Descripción</th> <th>Marca</th> <th>Prec/unid</th> <th>Costo Total</th> </tr> </table> <table id="1"> <tr> <td>1</td> <td>0</td> <td>3</td> <td>C/U</td> <td>Descripcion 1.</td> <td> <input id="marca1" class="inputcotiza1" style='width: 80px;' type="text" onchange="totalItem('costo_tot1','3','prec_unit1')" name="marca1"/> </td> <td> <input id="prec_unit1" class="inputcotiza2" style='width: 50px;' type="text" onchange="totalItem('costo_tot1','3','prec_unit1')" name="prec_unit1"/> </td> <td> <input id="costo_tot1" class="inputcotiza2" style='width: 50px;' type="text" disabled="" name="costo_tot1"/> </td> <td> <!--<a class="" onclick="agregarItem()"> <b>Añadir</b> </a>--> <input type="button" onClick="addPerson('1')" value="Añadir" > </td> </tr> </table> <table id="2"> <tr> <td>1</td> <td>0</td> <td>3</td> <td>C/U</td> <td>Descripcion 1.</td> <td> <input id="marca1" class="inputcotiza1" style='width: 80px;' type="text" onchange="totalItem('costo_tot1','3','prec_unit1')" name="marca1"/> </td> <td> <input id="prec_unit1" class="inputcotiza2" style='width: 50px;' type="text" onchange="totalItem('costo_tot1','3','prec_unit1')" name="prec_unit1"/> </td> <td> <input id="costo_tot1" class="inputcotiza2" style='width: 50px;' type="text" disabled="" name="costo_tot1"/> </td> <td> <!--<a class="" onclick="agregarItem()"> <b>Añadir</b> </a>--> <input type="button" onClick="addPerson('2')" value="Añadir" > </td> </tr> <!--</table></td> </tr>--> <tr> <td align="right"></td> </tr> </table> <table> <tr> <td align="center"><input type="submit" name="enviar" value="Enviar"></td> </tr> </table> </form> </body> </html>
y este es es script php, y no me trae los datos del formulario me podrias dar una manito. y ademas como haria para pasar los valores de item 1 (descripcion) al nuevo input generado dinamicamente y tambien poder usar la funcion onchange="totalItem('costo_tot1','3','prec_unit1')" dentro de los inputs nuevos que genere muchas gracias
<?
//Insertamos los diferentes registros del formulario if (isset($_POST["item"])){ foreach ($_POST["item"] as $indice => $item) { echo "item".$item; echo "alt".$alt=$_POST["alt"][$indice]; echo "cant".$cant=$_POST["cant"][$indice]; echo "unid".$unid=$_POST["unid"][$indice]; echo $descripcion=$_POST["descripcion"][$indice]; echo $marca=$_POST["marca"][$indice]; echo $prec_unit=$_POST["prec_unit"][$indice]; echo $query="INSERT INTO tabla (item,alt,cant,unid,desc,marca,prec_unit) VALUES ('$item','$alt','$cant','$unid','$marca','$prec_unit')"; mysql_query($query); } } ?>
|
|
|
| |

leotrux
|
|
 |
 |
| 12/11/2007 17:18 |
 |

Registrado: 07/11/2007
Nº mensajes: 5
 |
|
 |
|
| |

leotrux
|
|
 |
 |
| 14/11/2007 17:21 |
 |

Registrado: 07/11/2007
Nº mensajes: 5
 |
|
 |
|
| |

leotrux
|
|
 |
 |
| 16/04/2008 23:20 |
 |

Registrado: 16/04/2008
Nº mensajes: 6
 |
|
 |
|
| |
|
|
 |
 |
| 17/04/2008 15:23 |
 |

Registrado: 16/04/2008
Nº mensajes: 6
 |
|
 |
| |
rodpat |

|
|
 |
| |
Hola Living, muchas gracias por tu respuesta...
Lo que tengo que hacer es, consulto por un codigo, entonces si encuentro datos relacionados los imprimo en una tabla, digamos personas, imagina que para el codigo 1 existen dos personas...mostrandome los datos de esas personas, pero ademas si quiero agregar otra persona mas o modificar alguna de las personas que ya tiene asociadas, cambiarles la direccion, etc...
Por eso cuando necesito agregar otra persona necesito tu script, pero al enviar los datos, se pierden los anteriores, osea, solo me envia tantos datos como filas nuevas vaya cerando, pero para este ejemplo, los datos de las personas anteriores no "viajan" ... y como te digo todos los datos pueden ser modificables, ahora, me dices que si se puede, puedes ejemplificarme mas por favor?... para poder sacarlo pues estoy detenido solo en eso...y asi poder guardar todos los datos...
saludos
rodpat
|
|
|
| |
|
|
 |
 |
|