Muchas Gracias pero no me funciona. Un amigo me estuvo ayudando pero no logro mostrar los calculos. Deberian mostrarse automaticamente al introducir una cantidad en la casilla de cantidad. Este es el codigo:
Código PHP:
<?php
include ('func.php');
$ruta = '.';
do_html_header();
$conexion = db_connect();
$catid = $_GET['catid'];
if($catid == '' || !isset($catid)){
$catid = $_POST['catid'];
} $sql = mysql_query('SELECT catid, price FROM products');
$registros = array();
while ($registro2 = mysql_fetch_array($sql)) {
$registros[$registro2['catid']] = $registro2['price'];
}
?>
<html>
<body leftmargin="0" topmargin="0">
<table width="530" border="1" align="center">
<form name="form1" method="post" action="cotizacion.php">
<tr>
<td width="167" bgcolor="#CCCFD6" class="style15"><div align="center" class="Estilo2">MODELO</div></td>
<td width="126" bgcolor="#CCCFD6" class="style15"><div align="center" class="Estilo2">PRECIO</div></td>
<td width="57" bgcolor="#CCCFD6" class="style15"><div align="center"><span class="Estilo2">CANTIDAD</span></div></td>
<td width="57" bgcolor="#CCCFD6" class="style15"><div align="center"><span class="Estilo2">TOTAL</span></div></td>
</tr>
<?php
foreach($registros as $id => $price) {
//$total = (isset($_POST['cant-' . $catid])) ? $_POST['cant-' . $catid] * $price : 0;
$cantidad = (isset($_POST['cant-' . $price])) ? $_POST['cant-' . $price] * 1 : 0;
$total = $cantidad * $price;
echo "
<tr>
<td align=\"center\"><input type=\"text\" name=\"catid[]\" value=\"$id\" size=\"20\" /></td>
<td align=\"center\"><input type=\"text\" name=\"price[]\" value=\"$price\" size=\"10\" /></td>
<td align=\"center\"><input name=\"cant-$catid\" type=\"text\" id=\"cant-$catid\" size=\"10\" value=\"$cantidad\" /></td>
<td align=\"center\" class=\"style15\">$total</td>
</tr>";
}
?>
</form>
</table>
</body>
</html>
Por favor amigos de verdad necesito ayuda, no he dormido y tengo que entregar esto hoy. Gracias.