a partir de un nuevo campo dado en la pagina php, se cree un nuevo registro en la bd
aqui la imagen

bueno como se ve ahi, al darle cilick a agregar campo, se agrega uno nuevo y con eliminar lo borra claro está, entonces yo quiero guardar esos nuevos datos a la base de datos, se que se necesita el codigo de alter table, ok pero como lo utilizo??, porque tal vez hoy creo un registro de 3 productos, pero mañana uno de 2 o de 6, como resuelvo este problema?,
y por si fuera poco una pregunta mas, como sumo dinamicamente esos campos nuevos creados, para el costo total, subtotal, y el calculo del iva y el total??
aca el codigo que tengo hasta ahora
(no me regañen,esta hecho en dreamweaver)
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cotizaciones</title>
<style type="text/css">
<!--
.Estilo3 {
font-size: 14px
}
.Estilo5 {font-size: 14}
.Estilo7 {
font-size: 16px;
font-weight: bold;
}
.Estilo9 {
font-size: 12px;
font-weight: bold;
}
.Estilo10 {font-size: 12px}
.Estilo14 {
font-size: 20px;
font-weight: bold;
}
-->
</style>
</head>
<body onload="document.cotiza.c_empresa.focus()">
<style type="text/css">
.mayus {
text-transform: uppercase;
}
</style>
<script language="javascript" type="text/javascript">
var indiceFilaFormulario = 1;
function addCampo(){
newFila = document.getElementById("formCampos").insertRow(-1);
newFila.id = indiceFilaFormulario;
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<td><label>" +indiceFilaFormulario+ "</label></td>";
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<td><input type = 'text' name = 'c_cantidad["+indiceFilaFormulario+"]' size='5' maxlength='5' class='mayus'></td>";
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<td><textarea name = 'c_modelo["+indiceFilaFormulario+"]' cols='40' rows='5' class='mayus'></textarea></td>";
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<td><input type = 'text' name = 'c_tiempoEntrega["+indiceFilaFormulario+"]' size='10' maxlength='10' class='mayus'></td>";
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<td><input type = 'text' name = 'c_costoUnitario["+indiceFilaFormulario+"]' size='10' maxlength='10' ></td>";
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<td><input type = 'text' name = 'c_costoTotal["+indiceFilaFormulario+"]' size='10' maxlength='10'></td>";
newCelda = newFila.insertCell(-1);
newCelda.innerHTML = "<th><input type = 'button' value='Eliminar' onclick='delCampo(this)' ></th>";
indiceFilaFormulario++;
incr++;
}
function delCampo(obj){
var oTr = obj;
while (oTr.nodeName.toLowerCase()!='tr'){
oTr = oTr.parentNode;
}
var root = oTr.parentNode;
root.removeChild(oTr);
indiceFilaFormulario--;
}
</script>
<form id="cotiza" name="cotiza" method="post" action="" >
<table width="852" height="865"border="1" align="center" bordercolor="#000000">
<tr>
<td width="173" height="150" rowspan="3"><p class="Estilo3"> </p> </td>
<td colspan="4" rowspan="3"><div align="center" class="Estilo3"><a href="/SCI/index.php"></a></div></td>
<td height="31" colspan="3"> </td>
</tr>
<tr>
<td width="33" height="26"><div align="center" class="Estilo3">e-mail: </div></td>
<td colspan="2"> </td>
</tr>
<tr>
<td height="40" colspan="3"> </td>
</tr>
<tr>
<td height="9"><span class="Estilo9">Compañia:</span></td>
<td colspan="4"><label>
<input name="c_empresa" type="text" id="c_empresa" tabindex="1" value="" size="50" class="mayus"/>
</label></td>
<td colspan="3" rowspan="5"> </td>
</tr>
<tr>
<td height="17"><span class="Estilo10">AT'N:</span></td>
<td colspan="4"><label>
<input name="c_cliente" type="text" id="c_cliente" tabindex="2" size="50" class="mayus"/>
</label></td>
</tr>
<tr>
<td height="17"><span class="Estilo10">C.C:</span></td>
<td colspan="4"><label>
<input name="c_CC" type="text" id="c_CC" tabindex="3" size="50" class="mayus"/>
</label></td>
</tr>
<tr>
<td height="17"><span class="Estilo10">FECHA (dd / mm / aaaa):</span></td>
<td width="64">
<div align="center">
<input name="c_fechaD" type="text" id="c_fechaD" tabindex="4" size="3" maxlength="2" />
/ </div></td>
<td width="54"><div align="center">
<input name="c_fechaM" type="text" id="c_fechaM" tabindex="5" size="3" maxlength="2" />
/</div></td>
<td width="36"><div align="center">
<input name="c_fechaA" type="text" id="c_fechaA" tabindex="6" size="5" maxlength="4" />
</div></td>
<td width="302"> </td>
</tr>
<tr>
<td height="17"><span class="Estilo10">DE:</span></td>
<td colspan="4"> </td>
</tr>
<tr>
<td height="26" colspan="8"><div align="center"><span class="Estilo7">C O T I Z A C I O N</span></div></td>
</tr>
<tr>
<td height="291" colspan="8" align="left" valign="top">
<label></label> <label></label> <label></label> <label></label> <label></label>
<table width="842" border="0" id="formCampos">
<tr>
<th width="49" scope="col"><div align="center">No</div></th>
<th width="70" scope="col"><div align="center">Cantidad</div></th>
<th width="426" scope="col"><div align="center">Modelos / Descripción</div></th>
<th width="129" scope="col"><div align="center">Tiempo de Entrega</div></th>
<th width="81" scope="col"><div align="center">Precio Unitario</div></th>
<th width="61" scope="col"><div align="center">Costo Total</div></th>
<th width="61" scope="col"><div align="center">Eliminar</div></th>
</tr>
</table>
<br />
<label>
<input type="button" onclick="addCampo()" value="Agregar Campo" />
</label></td>
</tr>
<tr>
<td height="96" colspan="6" rowspan="3"><div align="center"></div></td>
<td width="77" height="21"><span class="Estilo3"><strong>SUBTOTAL</strong></span></td>
<td width="61" align="center">
<input name="c_subtotal" type="text" id="c_subtotal" tabindex="13" size="10" readonly="readonly" /></td>
</tr>
<tr>
<td height="21"><span class="Estilo3"><strong>I.V.A.</strong></span></td>
<td align="left"><div align="center">15%</div></td>
</tr>
<tr>
<td height="21"><span class="Estilo3"><strong>TOTAL</strong></span></td>
<td align="center">
<input name="c_total" type="text" id="c_total" tabindex="14" size="10" readonly="readonly"/>
</td>
</tr>
<tr>
<td height="23" colspan="8">*** Vigencia de la cotizaciòn 15 dìas apartir de la fecha de envio </td>
</tr>
<tr>
<td height="23" colspan="8">*** Una vez autorizada y colocada la orden de compra NO se aceptan cancelaciones después de 24:00 hras.</td>
</tr>
<tr>
<td height="23" colspan="8">*** En todas las Herramientas Especiales NO se aceptan devoluciones, ya que son NO cancelables y NO retornables.</td>
</tr>
<tr>
<td height="23" colspan="8"> *** En productos especiales nos reservamos el derecho de entrega +/-10% de la cantidad ordenada.<br /></td>
</tr>
<tr>
<td height="23" colspan="8">Los precios son en<strong>
<label>
<select name="moneda">
<option value="1">Moneda Nacional</option>
<option value="2">Dolares</option>
</select>
</label>
</strong></td>
</tr>
<tr>
<td height="23" colspan="8"><div align="center"><span class="Estilo5">*Le agradecemos la oportunidad de cotizarle, estamos a sus órdenes para cualquier información complementaria*</span></div></td>
</tr>
</table>
</form>
<p align="center"><a href="/SCI/index.php">Pagina Principal</a></p>
</body>
</html>
de antemano gracias
aaa si, los datos de conexion a la base no hay problema, lo que necesito en si es lo que pregunto jaja xD

