Hi Guys,
I'm trying to write some simple calculations using javascript in a web page. They don't work, can anyone see where I'm going wrong?
HTML
And Javascript:HTML Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Thanks to LGB for the basic site template--> <html> <head> <title>Simple Calculators</title> <meta name="Generator" content="TextPad 4.6"> <meta name="Author" content="?"> <meta name="Keywords" content="?"> <meta name="Description" content="?"> <link rel="stylesheet" type="text/css" href="simple.css"> <script language = "javaScript" type="text/javascript" src="script01.js"> </script> </head> <body> <!--This should be the same in all the pages just change the heading text. --> <div id="titlepart"> <h1>Simple Calculators</h1> <hr /><br> </div> <div id="menupart"> <h3><a href="simplehome.htm">Home</a></h3> <h3><a href="simplekanban.htm">Kan Ban</a></h3> <h3><a href="simplesafety.htm">Safety Stock</a></h3> <h3><a href="simplerol.htm">Re-order Levels</a></h3> <h3><a href="simpleeoq.htm">EOQ</a></h3> <h3><a href="simplecontact.htm">Contact</a></h3> </div> <!-- Edit this part ONLY --> <div id="mainpart"> <h2>Re-Order Level (ROL)</h2> <p>The ROL is used to deterime a point at which an order is placed for material. This in itself is a very simple calculation using the average demand, lead time and safety stock previously calculated.</p> <p>It is often used in conjuction with the Economic Order Quantity (EOQ) which helps to determine how much to order.</p> <br /> <form name="frmOne"> <p><label>Safety Stock:<input type="text" size="10" name="txtsafety"/></label></p> <p><label>Average Demand:<input type="text" size="10" name="txtdemand"/></label></p> <p><label>Standard Lead Time:<input type="text" size="10" name="txtleadtime"/></label></p> <p><label><input type="Button" value="Calculate" size="50" onClick="calculate()"/></label></p> <p><label>Result<input type="Text" size="10" name="txtresult" /></label></p> </form> </div> </body> </html>
Any ideas/tips would be welcome.Code:function calculate() { var A = parseFloat(document.formOne.txtsafety.value); var B = parseFloat(document.formOne.txtdemand.value); var C = parseFloat(document.formOne.txtleadtime.value); document.frmOne.txtresult.value = A+(B*C); }




Reply With Quote