este es mi codigo
Código PHP:
function fEscribeDir()
{
addFormField(document.formu1,'text',+i);
//document.formu1.numficheros.value=i;
i=i+1;
}
function addFormField (form, fieldType, fieldName, fieldValue)
{
rows = parseInt(rows) + 1;
//var fila = document.createElement("TR");
var cont = document.getElementById("cont");
var fila = document.createElement('TR'); //fila
var cel1 = document.createElement("TD"); //celda1
var cel2 = document.createElement("TD"); //celda1
var cel3 = document.createElement("TD"); //celda1
var cel4 = document.createElement("TD"); //celda1
var cel5 = document.createElement("TD"); //celda1
var cel6 = document.createElement("TD"); //celda1
var cel7 = document.createElement("TD"); //celda1
var cel8 = document.createElement("TD"); //celda1
var cel9 = document.createElement("TD"); //celda1
var cel10 = document.createElement("TD"); //celda1
var cel11= document.createElement("TD"); //celda1
var cel12 = document.createElement("TD"); //celda1
var tabla = document.getElementById("ficheros").tBodies[0];
var fec = document.createElement('INPUT');
var cod = document.createElement('INPUT');
var det = document.createElement('INPUT');
var tal = document.createElement('INPUT');
var sto = document.createElement('INPUT');
var can = document.createElement('INPUT');
var pre = document.createElement('INPUT');
var des = document.createElement('INPUT');
var pre_t = document.createElement('INPUT');
var use = document.createElement('INPUT');
var f_p = document.createElement('INPUT');
var boton = document.createElement('INPUT');
boton.setAttribute('type','button');
boton.setAttribute('value','Borrar');
boton.onclick=function(){borrarFila(this);}
fec.value = document.all.txtfecha.value;
cod.value = document.all.txtcod.options [document.all.txtcod.selectedIndex].text;
det.value = document.all.txtdet.value;
tal.value = document.all.txt_talle.value;
sto.value = document.all.stock.value;
can.value = document.all.cant.value;
pre.value = document.all.cost_u.value;
des.value = document.all.desc.value;
pre_t.value = document.all.txt_tot.value;
use.value = document.all.txtuser.options [document.all.txtuser.selectedIndex].text;
f_p.value = document.all.txtfp.value;
fec.setAttribute("name","fec[]" );
cod.setAttribute("name","cod[]" );
det.setAttribute("name","det[]" );
tal.setAttribute("name","tal[]" );
sto.setAttribute("name","sto[]" );
can.setAttribute("name","can[]" );
pre.setAttribute("name","pre[]" );
des.setAttribute("name","des[]" );
pre_t.setAttribute("name","pre_t[]" );
use.setAttribute("name","use[]" );
f_p.setAttribute("name","f_p[]" );
fec.style.width="70px";
cod.style.width="120px";
det.style.width="375px";
tal.style.width="45px";
sto.style.width="45px";
can.style.width="60px";
pre.style.width="55px";
des.style.width="60px";
pre_t.style.width="65px";
use.style.width="145px";
f_p.style.width="80px";
cel1.style.width="70px";
cel2.style.width="120px";
cel3.style.width="375px";
cel4.style.width="45px";
cel5.style.width="45px";
cel6.style.width="60px";
cel7.style.width="55px";
cel8.style.width="60px";
cel9.style.width="65px";
cel10.style.width="145px";
cel11.style.width="80px";
cel12.style.width="50px";
cel2.align ="center";
cel1.appendChild(fec);
cel2.appendChild(cod);
cel3.appendChild(det);
cel4.appendChild(tal);
cel5.appendChild(sto);
cel6.appendChild(can);
cel7.appendChild(pre);
cel8.appendChild(des);
cel9.appendChild(pre_t);
cel10.appendChild(use);
cel11.appendChild(f_p);
cel12.appendChild(boton);
fila.appendChild(cel1);
fila.appendChild(cel2);
fila.appendChild(cel3);
fila.appendChild(cel4);
fila.appendChild(cel5);
fila.appendChild(cel6);
fila.appendChild(cel7);
fila.appendChild(cel8);
fila.appendChild(cel9);
fila.appendChild(cel10);
fila.appendChild(cel11);
fila.appendChild(cel12);
tabla.appendChild(fila);
//div.appendChild(input);
//document.getElementById('ficheros').appendChild(div);
//document.all.txtfec[i]= fecha;
document.all.pagar.value = parseInt(pre_t.value) + parseInt(document.all.pagar.value)
}
function borrarFila(button){
var fila = button.parentNode.parentNode;
var tabla = document.getElementById('ficheros').getElementsByTagName('tbody')[0];
tabla.removeChild(fila);
}
</script>
<link rel="stylesheet" type="text/css" href="estilos.css">
<style>
<!--
.Estilo2 {
font-size: 25px;
COLOR: black;
}
-->
</style>
</head>
<body class="fondo">
<form name="datos" action="ventas.php" method="POST">
<input name="cont" type="hidden" id="cont" value="0" >
<table width="100%" border="3">
<tr>
<td class="nombrecampo"><span class="Estilo1">FECHA</span></td>
<td class="nombrecampo"><span class="Estilo1">Nº CODIGO</span></td>
<td class="nombrecampo"><span class="Estilo1">DETALLE</span></td>
<td class="nombrecampo"><span class="Estilo1">TALLE</span></td>
<td class="nombrecampo"><span class="Estilo1">STOCK</span></td>
<td class="nombrecampo"><span class="Estilo1">CANTIDAD</span></td>
<td class="nombrecampo"><span class="Estilo1">PRECIO U.</span></td>
<td class="nombrecampo"><span class="Estilo1">DESC.</span></td>
<td class="nombrecampo"><span class="Estilo1">PRECIO TOTAL</span></td>
<td class="nombrecampo"><span class="Estilo1">USUARIO</span></td>
<td class="nombrecampo"><span class="Estilo1">FORMA PAGO</span></td>
</tr>
<tr>
<td class="nombrecampo"><span class="Estilo1"><input name="txtfecha" id="txtfecha" type="text" size="7" maxlength="10"value="<?php echo $fec = fecha_servidor_total() ?>" onKeyUp="mascara(this,'/',patron,true);" onBlur=" esFechaValida(this);" ></span></td>
<td class="nombrecampo"><span class="Estilo1" >
<select name="txtcod" onclick='ver_cod()' tabindex="3">
<option value="Seleccione Tipo" selected>Ingrese Codigo
<?php
// CODIGO PHP
// Contruimos el primer combo con los valores de la tabla 'centros'.
$db= Conec_con_pass();
$cons_centros = @pg_exec($db, "SELECT * FROM stock inner join prendas on stock.idprenda = prendas.idprenda ;");
for ($k = 0; $k < pg_numrows($cons_centros); ++$k)
{
$centro = @pg_fetch_object($cons_centros, $k);
echo " <option title=\"".$centro->detalle."\" id=\"".$centro->p_vta."\" value=\"".$centro->cant_pa."\">".$centro->codigo."\n";
}
?>
</select></span>
</td>
<TD class="nombrecampo"><span class="Estilo1"><input type="text" name="txtdet" size="50"></span></TD>
<td class="nombrecampo"><span class="Estilo1"><input type="text" name="txt_talle" size="3"></span></td>
<TD class="nombrecampo"><span class="Estilo1"><input type="text" name="stock" size="3" value="1"></span></TD>
<TD class="nombrecampo"><span class="Estilo1"><input type="text" name="cant" size="4" value="1"></span></TD>
<TD class="nombrecampo"><span class="Estilo1"><input type="text" name="cost_u" size="5"></span></TD>
<TD class="nombrecampo"><span class="Estilo1"><input type="text" name="desc" size="5" onBlur="porc()"></span></TD>
<TD class="nombrecampo"><span class="Estilo1"><input type="text" name="txt_tot" size="5" value="0"></span></TD>
<td class="nombrecampo"><span class="Estilo1" >
<select name="txtuser" onclick='ver_user()' tabindex="3">
<option value="Seleccione usuario" selected>Seleccione Usuario
<?php
// CODIGO PHP
// Contruimos el primer combo con los valores de la tabla 'centros'.
$db= Conec_con_pass();
$cons_centros = @pg_exec($db, "SELECT * FROM USUARIO;");
for ($k = 0; $k < pg_numrows($cons_centros); ++$k)
{
$centro = @pg_fetch_object($cons_centros, $k);
echo " <option value=\"".$centro->idusuario."\">".$centro->usuario."\n";
}
?>
</select></span>
</td>
<label>
<td class="nombrecampo" ><span class="Estilo1">
<select name="txtfp">
<option value="CONTADO">CONTADO</option>
<option value="TARJETA">TARJETA</option>
</select>
</td></label>
<td class="nombrecampo"><span class="Estilo1"><input type="hidden" name="txtcod_num"></span></td>
<td class="nombrecampo"><span class="Estilo1"><input type="button" value="insertar" name="txtgrabar" onClick="javascript: fEscribeDir();"></span></td>
</tr>
</table>
<table width="100%" border="1" id="ficheros" class="ingresodatos" align="center">
<TD colspan="12" align="center" style="font-size:20px" style="color:#000033" ><b>DETALLE</b><TD>
</table>
<table align="right">
<td ><span class="Estilo2"><b>TOTAL PESOS: $<b><input style="font-size:24px" size="4" style="color:black;" type="text" name="pagar" value="0" ></span></td>
<td><input type="submit" id="enviar"></td>
</table>
</form>
</body>
</html>