Bueno, utilizo firefox 3.0.6 bajo kubuntu intrepid.En IE no lo puedo probar directamente, pero tampoco me interesa porque la página sólo se va a ejecutar en firefox.
Sigo probando y te comento. Gracias por seguir el hilo :)
He conseguido algo! Volví a la idea de los input text con nombre proveedor1, en vez de proveedor[1]
ahora sí envía los datos. Cuando hago esto
Cita: for($i = 1; $i < $total; $i++ ) {
$proveedor = $_POST['proveedor'.$i];
$especie = $_POST['especie'.$i];
$kilos = $_POST['kilos'.$i];
$precio = $_POST['precio'.$i];
$subtotal = $_POST['subtotal'.$i];
if(!$proveedor && !$especie){ $error="si"; } else { $error="no";
mysql_query("INSERT INTO registros_facturas (id_factura, proveedor, especie, kilos, precio, subtotal) values (".$_POST['num_fact'].",'".$proveedor."','".$especie."',".$kilos.",".$p recio.",".$subtotal.");");
}
Pasa a $error="no";
pero no inserta los registros!! ¿Cómo es posible?
Bueno, lo he conseguido!!!! ¿Cómo? El código, el siguiente:
Código PHP:
$total = $_POST['cuantosreg'];
for($i = 0; $i <= $total; $i++ ) {
$proveedor = $_POST['proveedors'.$i];
$especie = $_POST['especies'.$i];
$kilos = $_POST['kiloss'.$i];
$precio = $_POST['precios'.$i];
$subtotal = $_POST['subtotals'.$i];
if($proveedor=="" && $especie==""){ } else {
$numfactura=$_POST['num_fact'];
mysql_query("INSERT INTO registros_facturas (id_factura, proveedor, especie, kilos, precio, subtotal) values ('".$_numfactura."', '".$proveedor."', '".$especie."', '".$kilos."', '".$precio."', '".$subtotal."');");
}
}
y lleno los registros con javascript así:
Código:
unction insertar() {
var proveedor=document.facturacion.proveedor.value;
var especie=document.facturacion.especie.value;
var kilos=document.facturacion.kilos.value;
var precio=document.facturacion.precio.value;
var subtotal=document.facturacion.subtotal.value;
var cuantosreg=document.facturacion.cuantosreg.value;
var total=document.facturacion.total.value;
cuantosreg=Number(cuantosreg)+1;
document.facturacion.cuantosreg.value=cuantosreg;
document.getElementById("contenidoFactura").innerHTML+="<div id='registro"+cuantosreg+"'><table width=100% style=font-size:8pt; border=0 cellspacing=0 cellpadding=5>
<TR><TD width=18% align=center>"+proveedor+"<input type=hidden name=proveedors"+cuantosreg+" id=proveedors"+cuantosreg+" value='"+proveedor+"'></TD>
<TD width=18% align=center>"+especie+"<input type=hidden name='especies"+cuantosreg+"' id='especies"+cuantosreg+"' value='"+especie+"'></TD>
<TD width=18% align=center>"+kilos+" Kg<input type=hidden name='kiloss"+cuantosreg+"' id='kiloss"+cuantosreg+"' value='"+kilos+"'></TD>
<TD width=18% align=center>$ "+precio+" / Kg<input type=hidden name='precios"+cuantosreg+"' id='precios"+cuantosreg+"' value='"+precio+"'></TD>
<TD width=18% align=right><b>$ "+subtotal+"</b><input type=hidden name='subtotals"+cuantosreg+"' id='subtotals"+cuantosreg+"' value='"+subtotal+"'></TD>
<td width=10% align=center><a href=javascript:eliminarReg("+cuantosreg+");>Eliminar</a></td></TR></table></div>";
total=Number(total)+Number(subtotal);
total=total.toFixed(2);
document.facturacion.proveedor.value="";
document.facturacion.especie.value="";
document.facturacion.kilos.value="";
document.facturacion.precio.value="";
document.facturacion.subtotal.value="0.00";
document.facturacion.total.value=total;
}
Un saludo y gracias!