hi, I'm new to JS but i'm trying to make a price comparison calculator for a friend of mine.
But i can't figure out how to have the answer overwrite the question and forms.
I thought about a switch statement but i don't quite know how to use it.
But since i messed all attempts up i'll just send in one that works.
This is what i hope it will look like.
function CalculateSum(Atext, Btext, form)
var A = parseFloat(Atext);
var B = parseFloat(Btext);
form.Answer.value = A - (B*0.98);
<FORM NAME="Calculator" METHOD="post">
<P>Current montly amount: <INPUT TYPE=TEXT NAME="input_A" SIZE=10></P>
<P>Cups per month.: <INPUT TYPE=TEXT NAME="input_B" SIZE=10></P>
<P><INPUT TYPE="button" VALUE="Calculate" name="AddButton" onClick="CalculateSum(this.form.input_A.value, this.form.input_B.value, this.form); document.write(You would save"></P>
<P>You would save = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
best regards... Gisli