green9knight
07 Jan 2011, 02:32 PM
I am trying to adapt a script to work with a more complex problem than it was designed for. It is for my blog. Please help I cant get it to calculate.
<script language="JavaScript">
function calculate(Atext,Btext,Ctext,Dtext,E, form) {
E = [(Atext + Btext)- Ctext] / Dtext;}
return E;
var A = parseFloat(Atext);
var B = parseFloat(Btext);
var C = parseFloat(Ctext);
var D = parseFloat(Dtext);
form.Answer.value = E
}
/* ClearForm: this function has 1 argument: form.
It clears the input and answer fields on the form.
It needs to know the names of the INPUT elements in order
to do this. */
function ClearForm(form)
{
form.input_A.value = "";
form.input_B.value = "";
form.input_C.value = "";
form.input_D.value = "";
form.Answer.value = "";
}
// end of JavaScript functions -->
</script>
<form name="Calculator" method="post">
<p>Market Cap: <input type="TEXT" name="input_A" size="10" /></p>
<p>Debt: <input type="TEXT" name="input_B" size="10" /></p>
<p>Cash: <input type="TEXT" name="input_C" size="10" /></p>
<p>EBIT: <input type="TEXT" name="input_D" size="10" /></p>
<p><input type="button" value="Calculate Numbers" name="AddButton" onclick="CalculateSum(this.form.input_A.value, this.form.input_B.value,this.form.input_C.value,
this.form.input_D.value,)" /></p>
<p><input type="button" value="Clear Fields" name="ClearButton" onclick="ClearForm(this.form)" /></p>
<p>Answer = <input type="TEXT" name="Answer" size="12" /></p>
</form>
<script language="JavaScript">
function calculate(Atext,Btext,Ctext,Dtext,E, form) {
E = [(Atext + Btext)- Ctext] / Dtext;}
return E;
var A = parseFloat(Atext);
var B = parseFloat(Btext);
var C = parseFloat(Ctext);
var D = parseFloat(Dtext);
form.Answer.value = E
}
/* ClearForm: this function has 1 argument: form.
It clears the input and answer fields on the form.
It needs to know the names of the INPUT elements in order
to do this. */
function ClearForm(form)
{
form.input_A.value = "";
form.input_B.value = "";
form.input_C.value = "";
form.input_D.value = "";
form.Answer.value = "";
}
// end of JavaScript functions -->
</script>
<form name="Calculator" method="post">
<p>Market Cap: <input type="TEXT" name="input_A" size="10" /></p>
<p>Debt: <input type="TEXT" name="input_B" size="10" /></p>
<p>Cash: <input type="TEXT" name="input_C" size="10" /></p>
<p>EBIT: <input type="TEXT" name="input_D" size="10" /></p>
<p><input type="button" value="Calculate Numbers" name="AddButton" onclick="CalculateSum(this.form.input_A.value, this.form.input_B.value,this.form.input_C.value,
this.form.input_D.value,)" /></p>
<p><input type="button" value="Clear Fields" name="ClearButton" onclick="ClearForm(this.form)" /></p>
<p>Answer = <input type="TEXT" name="Answer" size="12" /></p>
</form>