473,472 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding an amount to an integer......

47 New Member
i'll try and explain this as best i can.

i have a form with 3 radio buttons.

they have 3 values, 0, 5 and 10.

when the checkbox is checked, it adds that ammount to the total figure, currently 0.

i can't get it to work, maybe one of you guys could have a look at the code and tell where i'm going wrong, thanks.

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript1.2">
  2.  
  3. function calculateTotal()
  4.  
  5. {
  6.     var price,i;
  7.  
  8. for (i=0; i<document.formTotal.shipping.length;i++)
  9.     {
  10.         if (document.formTotal.shipping.checked=true)
  11.         {
  12.             parseInt (document.formTotal.total + 5);
  13.         }
  14.     }    
  15.  
  16. </script>
  17.  
  18.  



and the html.

Expand|Select|Wrap|Line Numbers
  1. <form name="formTotal" method="post" action="">
  2.  
  3.     <table width="100%" border="0" cellspacing="1" cellpadding="6">
  4.       <tr>
  5.         <td colspan="3" bgcolor="#FFF7D2"><span class="style3">Please choose your region for shipping </span></td>
  6.         </tr>
  7.       <tr>
  8.         <td align="center"><span class="style1"><strong>Ireland<br />
  9.         </strong>free </span><br />
  10.           <input name="shipping" type="radio" /></td>
  11.         <td align="center"><span class="style1"><strong>Other EU</strong><br />
  12.           &euro;5<br />
  13. </span>
  14.           <input name="shipping" type="radio" value="5" /></td>
  15.         <td align="center">&nbsp; <span class="style1"><strong>Rest of World</strong><br />
  16.           &euro;10<br />
  17. </span>
  18.           <input name="shipping" type="radio" value="10" /></td>
  19.       </tr>
  20.     </table>
  21. </form>
  22.       <table width="100%" border="0" cellspacing="1" cellpadding="6">
  23.         <tr>
  24.           <td colspan="2" bgcolor="#FFF7D2"><span class="style3">Shopping Cart </span></td>
  25.         </tr>
  26.         <tr>
  27.           <td><span class="style1">Quantity</span></td>
  28.           <td><span class="style1" id="quantity">0</span></td>
  29.         </tr>
  30.         <tr>
  31.           <td><span class="style1">Total</span></td>
  32.           <td><span class="style1" id="total">0</span></td>
  33.         </tr>
  34.       </table> 
  35.  
Oct 26 '07 #1
1 1046
gits
5,390 Recognized Expert Moderator Expert
hi ...

use:

Expand|Select|Wrap|Line Numbers
  1. parseInt(document.formTotal.total) + 5;
  2.  
kind regards
Oct 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
2
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only...
2
by: Ken Dippold | last post by:
Hello, I am trying to create textboxes in a table that has a certain amount of cells decided at run time. That is decided by the desc_flag. So if I have 7 cells the first 6 cells are empty and only...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
135
by: robinsiebler | last post by:
I've never had any call to use floating point numbers and now that I want to, I can't! *** Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) on win32. *** 0.29999999999999999 0.29999999999999999
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.