The_FedEx_Guy wrote:
> I'm just trying to subtract one number from another.
>
> The one I want to subtract is the one the User enters in
the textbox.
>
> I have tried to play around with it. And have followed a
Javascript example I
> found online but the value disappers once I press the
submit button.
>
> It will show it for a fraction of a second and then
blank.
>
> <SCRIPT LANGUAGE="JavaScript">
>
> function CalculateSum(Atext, Btext, form)
> {
> var A = parseFloat(Atext);
> var B = parseFloat(Btext);
> form.Answer.value = B - A;
> }
>
> </SCRIPT>
When you press the submit button you will be directed to
calc.php, thus
you need to add a button to your page:
<input type="button" name="calc"
value="Update"
onClick="CalculateSum(this.form.paid.value,
this.form.balance.value, this.form)"/>
Mick.
>
> <form id="form2" name="form2" method="post"
action="calc.php">
> <table width="500" border="0" align="center"
cellpadding="3"
> cellspacing="3">
> <tr>
> <td width="30" valign="top">Paid:</td>
> <td width="152" valign="top"><input type="text"
name="paid"
> id="paid" /></td>
> <td width="136" valign="top">New
Balance:</td>
> <td width="143" valign="top"><INPUT TYPE=TEXT
NAME="Answer"></td>
> </tr>
> <tr>
> <td valign="top"></td>
> <td valign="top"> </td><input
name="balance" type="hidden"
> value="<?php echo $row_total_cost['Total_Bal'];
?>" />
> <td valign="top"><input type="submit"
name="update" id="update"
> value="Update"
onClick="CalculateSum(this.form.paid.value,
> this.form.balance.value, this.form)"/></td>
> <td valign="top"> </td>
> </tr>
> </table>
> </form>
>
>
>