I'm trying to post a form on my website to calculate RMV. I have the form up, but when I click the calculate button nothing happens. It's probably something stupid, but I'm just starting out with javascript and can't figure it out.
Here's the code -
<head>
<script>
<!-- hide this script from old browsers
function RMV(form)
{
var p = parseFloat(form.PSI.value, 10);
var t = parseFloat(form.Time.value, 10);
var d = parseFloat(form.Depth.value, 10);
var c = parseFloat(form.Cylinder.value, 10);
var x = parseFloat(form.Rated.value, 10);
f = (c / x);
a = (p * f);
b = (a / t);
r = (b / d);
form.RMV.value = r;
}
<!-- done hiding from old browsers -->
</script>
</head>
<body>
<form>
<font color="#008000">Enter PSI used: <br /><input maxlength="4" size="4" name="p" />
</font>
<font color="#008000">Enter Time: <br /><input maxlength="2" size="2" name="t" />
</font>
<font color="#008000">Enter Depth: <br /><input maxlength="3" size="3" name="d" />
</font>
<font color="#008000">Enter Cylinder used: <br /><input maxlength="3" size="3" name="c" />
</font>
<font color="#008000">Enter Rated Pressure of Cylinder: <br /><input maxlength="4" size="4" name="x" />
</font>
<font color="#008000">Click this button to calculate your RMV:<br /><input onclick="RMV(this.form)" type="button" value="Calculate" name="calc" />
</font>
<font color="#008000">RMV is: <br /><input readonly size="3" name="RMV" />
</font>
</form>
Thanks for any help!
Here's the code -
<head>
<script>
<!-- hide this script from old browsers
function RMV(form)
{
var p = parseFloat(form.PSI.value, 10);
var t = parseFloat(form.Time.value, 10);
var d = parseFloat(form.Depth.value, 10);
var c = parseFloat(form.Cylinder.value, 10);
var x = parseFloat(form.Rated.value, 10);
f = (c / x);
a = (p * f);
b = (a / t);
r = (b / d);
form.RMV.value = r;
}
<!-- done hiding from old browsers -->
</script>
</head>
<body>
<form>
<font color="#008000">Enter PSI used: <br /><input maxlength="4" size="4" name="p" />
</font>
<font color="#008000">Enter Time: <br /><input maxlength="2" size="2" name="t" />
</font>
<font color="#008000">Enter Depth: <br /><input maxlength="3" size="3" name="d" />
</font>
<font color="#008000">Enter Cylinder used: <br /><input maxlength="3" size="3" name="c" />
</font>
<font color="#008000">Enter Rated Pressure of Cylinder: <br /><input maxlength="4" size="4" name="x" />
</font>
<font color="#008000">Click this button to calculate your RMV:<br /><input onclick="RMV(this.form)" type="button" value="Calculate" name="calc" />
</font>
<font color="#008000">RMV is: <br /><input readonly size="3" name="RMV" />
</font>
</form>
Thanks for any help!