CAN ANYONE HELP ?
Greetings all...
I'm not any good at java...yet.
However I was wondering if anyone can help me write a javascript calculator that will solve an equation for my father-in-laws website.
He wants to allow visitors to calculate a flow rate of gallons per minute (GPM) by entering 4 variables. Now I have the formula and have worked it in a spreadsheet but that is as far as I can go.
Whoever can help develop the script will have free exposure on the site, including your name, email and website contact info. As well as a big thank you!
The formula is laid out in excel like this....where A1, B1 are the cells
A1 = 29.81 * B1 * B2^2 * (B3/B4)^0.5
Example : B1 = .73 (Cd - Coefficient Drag)
B2 = .04375 (Orifice Diameter in Inches, entered as decimal)
B3 = 500 (PSI - Pounds/Inch^2)
B4 = 1.109 (S.G. - Specific Gravity)
So, the answer for the example should by 88.44 GPM/ Flow Rate
I know this is a big request but, it never hurts to ask...
-Todd
[1032 byte] By [
Tbergman] at [2007-9-27 19:16:36]

[nobr]i seem to get 0.8844233091282343 GPM as the flow rate, but anyway i have a solution for you that works in both IE6 and NETSCAPE7
-- html file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JScript" src="flowCalculator.js" type="text/javascript"></script>
</head>
<body>
<form name="flowEquation" id="flowEquation">
<label for="drag">Drag Coefficient</label> : <input id="drag" type="text" size="10"><br>
<label for="diameter">Diameter</label> : <input id="diameter" type="text" size="10"><br>
<label for="pressure">pressure</label> : <input id="pressure" type="text" size="10"><br>
<label for="gravity">specific gravity</label> : <input id="gravity" type="text" size="10"><br>
<input type="button" id="ok" value="Calculate" onClick="doCalc();"><br>
<label for="flowRate">FlowRate</label> : <input id="flowRate" readonly="true" type="text" size="10"><br>
</form>
</body>
</html>
- Java Script File -
function calculateFlow( drag, diameter, pressure, grav ) {
return (29.81 * drag * Math.pow( diameter, 2 ) * Math.pow( (pressure/grav), 0.5 ));
}
function doCalc() {
var dragValue = document.flowEquation.drag.value;
var diameterValue = document.flowEquation.diameter.value;
var pressureValue = document.flowEquation.pressure.value;
var gravityValue = document.flowEquation.gravity.value;
var flowRate = calculateFlow( dragValue, diameterValue, pressureValue, gravityValue );
document.flowEquation.flowRate.value = flowRate;
}
--
anyway if you email me i will sent the acutal files
radix_zero@hotmail.com
[/nobr]