Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiplying using html/java

Status
Not open for further replies.

unmlobo

MIS
Apr 11, 2003
64
US
Hola all, have a "how to" question. I have a form that I wrote (with the help of the you all) that takes a quantity, multiplies it by a fixed price then gives me the subtotal. Then at the bottom of the form it gives a grad total.

What I need to do is, before it displays the grand total I need it to multiply the grand total by 0.06750 then display it.

Below is the code that does this above minus the multipication stuff. I just cut and pasted it out of the table do there might be a few <table> tags missing.

Thanks everyone!!!



<script language="javascript" type="text/javascript">
function calculate(what)
{
// total_Price ALL Tixs_Requestes
what.unmform_Total_Price_all.value =
(what.unmform_Total_PriceA.value - 0)
+ (what.unmform_Total_PriceB.value - 0)
+ (what.unmform_Total_PriceC.value - 0)
+ (what.unmform_Total_PriceD.value - 0)
+ (what.unmform_Total_PriceE.value - 0)
+ (what.unmform_Total_PriceF.value - 0)
}
</script>

<tr>
<center>
<td>Group Size </td>
<td>Seat Type </td>
<td>Qty</td>
<td>Price</td>
<td>Sub Total </td>
</center>
</tr>
<tr>
<td valign="top" align="center" width="79">250+</td>
<td valign="top" align="center" width="85"><input readonly="readonly" align="middle" size="10" border="0" name="unmform_250Prim" value="Premium" /> </td>
<td valign="top" align="center" width="222"><input onkeyup="this.form.unmform_Total_PriceD.value = (this.form.unmform_Tix_RequestedD.value - 0) * (20.00 - 0);calculate(this.form)" size="10" border="0" name="unmform_Tix_RequestedD" /></td>
<td valign="top" align="center" width="97">$18.00</td>
<td valign="top" align="center" width="82"><input readonly="readonly" size="10" border="0" name="unmform_Total_PriceD" /><input type="hidden" name="unmform_LineBreak1" /> </td>
</tr>
<tr>
<td valign="top" align="center" width="79">250+</td>
<td valign="top" align="center" width="85"><input readonly="readonly" align="middle" size="10" border="0" name="unmform_250Silver" value="Silver" /></td>
<td valign="top" align="center" width="222"><input onkeyup="this.form.unmform_Total_PriceE.value = (this.form.unmform_Tix_RequestedE.value - 0) * (20.00 - 0);calculate(this.form)" size="10" border="0" name="unmform_Tix_RequestedE" /></td>
<td valign="top" align="center" width="97">$13.00</td>
<td valign="top" align="center" width="82"><input readonly="readonly" size="10" border="0" name="unmform_Total_PriceE" /><input type="hidden" name="unmform_LineBreak2" /> </td>
</tr>
<tr>
<td valign="top" align="center" width="79">250+</td>
<td valign="top" align="center" width="85"><input readonly="readonly" align="middle" size="10" border="0" name="unmform_250Cherry" value="Cherry" /></td>
<td valign="top" align="center" width="222"><input onkeyup="this.form.unmform_Total_PriceF.value = (this.form.unmform_Tix_RequestedF.value - 0) * (20.00 - 0);calculate(this.form)" size="10" border="0" name="unmform_Tix_RequestedF" /></td>
<td valign="top" align="center" width="97">$8.00</td>
<td valign="top" align="center" width="82"><input readonly="readonly" size="10" border="0" name="unmform_Total_PriceF" /><input type="hidden" name="unmform_LineBreak3" /> </td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>

</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;Grand Total</td>
<td>&nbsp;<input readonly="readonly" size="10" border="0" name="unmform_Total_Price_all" /></td>

</tr>

 
Given that you already have code that does addition using the + operator, and subtraction using the - operator, surely you could take an educated guess at how to multiply?

Have you tried anything?

P.S. JavaScript questions should be asked in forum216.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Code:
function calculate(what)
{
  // total_Price ALL Tixs_Requestes
 what.unmform_Total_Price_all.value =
    ((what.unmform_Total_PriceA.value - 0)
  + (what.unmform_Total_PriceB.value - 0)
  + (what.unmform_Total_PriceC.value - 0)
  + (what.unmform_Total_PriceD.value - 0)
  + (what.unmform_Total_PriceE.value - 0)
  + (what.unmform_Total_PriceF.value - 0)) * 0.06750
  }

Not tested it but would the above work? If not try

Code:
function calculate(what)
{
  // total_Price ALL Tixs_Requestes
 
    subtotal =
    (what.unmform_Total_PriceA.value - 0)
  + (what.unmform_Total_PriceB.value - 0)
  + (what.unmform_Total_PriceC.value - 0)
  + (what.unmform_Total_PriceD.value - 0)
  + (what.unmform_Total_PriceE.value - 0)
  + (what.unmform_Total_PriceF.value - 0);

  what.unmform_Total_Price_all.value = subtotal* 0.06750
  }

MrBelfry
 
Thanks for the help MrBelfry. The first code gave me some random number in the grand total. The second bit of code broke the code so no number appeared in the Grand Total.
 
[&nbsp;]

It appears that you want us to write your code for you.

Have you tried [red]ANYTHING[/red] to solve this problem? If so, show us. If not, get busy - We are NOT here to do YOUR job for you.

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
mmerlinn/BillyRayPreachersSon I have no intention of having anyone wrinting my code or doing my job as you assume. I can do that for myself. As with last bit of code someone provided which did not work I made it work but I could not have done it with out there help and that's what Im looking for. If you all would try to help others instead of policing the site maybe someone would give you your proper due.

Thanks for the HELP gents!!!
 
We do help others (you can check our stats out).

Policing the forums with respects to asking people to post on the correct forum helps keep the site in a good order, and enables people to find things relevant to the technology the are using - which is why I asked you to keep your JavaScript-related question to the JavaScript forum.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top