Hello, I'm design a PVC windows site , and I need to build something that will give you the price for the window based on the dimensions inserted.So the user should insert height , lenght and the script should deliver the price..How can I do this ? I really need your help... Thank you.
I assume you're going to charge by the square foot. User would input height in inches, and the width in inches. Then just multiply the two to get the area in sq. inches. You can do the math yourself. If you're doing it in PHP, check out this site: http://www.w3schools.com/php/php_forms.asp for a tutorial for working with forms.
I'm not free but rep would be nice J/K here is a solution. <!-- YOUR FORM --> <form action="?calculate" method="get"> Height : <input type="text" name="h" /> <br /> Width : <input type="text" name="w" /> <br /> <input type="submit" value="calculate"> </form> <!-- THE CODE TO CALCULATE COST --> <?php // SET HOW MUCH PER SQUARE FOOT $price_per_sqfoot = '1.00'; if( !$_GET["h"] and !$_GET["w"] ){ You need to set the values } else { $total_sq= $_GET["h"]*$_GET["w"]; $total_cost = $total_sq*$price_per_sqfoot; // output result echo "Your total cost: $total_cost"; } ?> Code (markup): I wrote that entirely from my head, I didn't test it but it is fairly simple. Should work.
Or in javascript: Height (ft) : <input id="txtHeight" type="text" /><br /> Width (ft) : <input id="txtWidth" type="text" /><br /> <input id="calculate" type="button" value="Calcultate"> <div id="result"></div> <script type="text/javascript"> document.getElementById("calculate").onclick=function() { var cost = "12.10"; //Cost per square ft var totalCost = Math.round(document.getElementById("txtHeight").value * document.getElementById("txtWidth").value * cost * 100) / 100; document.getElementById("result").innerHTML = "$" + totalCost; } </script> Code (markup):