I have created dynamic pricing forms within a e-commerce site using javascript and it works fine. However I would prefer my more complex pricing computations to be in a PHP file external to the HTML form. The calculations are fairly complex and I have got them all working using PHP however I am new to PHP and for the life of me cant figure out how to get the result of the calculations to be returned to the html form. The user can then "Add to Cart"
Here are very simple examples to try and explain
HTML form
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demoform</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="myform.php">
<label>Width<input type="text" name="width" id="width" size="6"></label><p>
<label>Length<input type="text" name="length" id="length" size="6" ></label><p>
<label>Price $</label> <input id="Price" readOnly size=6 name=Price><p>
<label for=otherprice></label><input id="otherprice" readOnly size=6 type=hidden
name=otherprice><p>
<input type="submit" name="submit" id="submit" value="Get Price" ><p>
<input id="addtocart" title="Add to Cart" onclick="return validate(this.form)" value="Add to Cart" type="submit" ?>
</form>
</body>
</html>
PHP File
<?php
$width=$_POST['width'];
$length=$_POST['length'];
$Area = $width*$length;
$total = $Area * .01;
$price = round($total * 100) / 100;
$otherprice = round($price * 1.2 * 100)/100 ;
?>
<?php echo "$price"?><br/>
<?php echo "$otherprice"?>
Instead of a new page opening is it possible for $price to be input into the HTML price field and for $otherprice to be input into the HTML otherprice (hidden) field within the demoform.html page
John