473,382 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Javascript calculator in form with php loop

1
Hi;

Im trying to get a calculator working in a form.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function startCalc<? echo $num; ?>(){
  3.   interval = setInterval("calc<? echo $num; ?>()",1);
  4. }
  5. function calc<? echo $num; ?>(){  
  6. for(i = 1; i < <? echo $reged_cars; ?>; i++){
  7.   calc_car<? echo $num; ?>_lic = document.autoSumForm.car<? echo $num; ?>_lic.value;
  8.   document.autoSumForm.car<? echo $num; ?>_lic_quote.value = (calc_car<? echo $num; ?>_lic * 1)
  9. }
  10.  
  11.      car<? echo $num; ?>_lic_total = document.autoSumForm.car<? echo $num; ?>_lic_quote.value;
  12.      document.autoSumForm.lic_quote.value = ((car<? echo $num; ?>_lic_total * 1)).toFixed(2);
  13.  
  14.   adminfee = document.autoSumForm.admin_fee_quoted.value;
  15.   total_car_lic = document.autoSumForm.lic_quote.value;
  16.   document.autoSumForm.quote_total.value = ((total_car_lic * 1) + (adminfee * 1)).toFixed(2);
  17.   }
  18. function stopCalc<? echo $num; ?>(){
  19.   clearInterval(interval);
  20. }
  21. </script>
  22.  
This semi works, it will place the figure from
Expand|Select|Wrap|Line Numbers
  1. document.autoSumForm.car<? echo $num; ?>_lic.value;
into
Expand|Select|Wrap|Line Numbers
  1. document.autoSumForm.car<? echo $num; ?>_lic_quote.value
and calculate
Expand|Select|Wrap|Line Numbers
  1. adminfee = document.autoSumForm.admin_fee_quoted.value;
  2.   total_car_lic = document.autoSumForm.lic_quote.value;
  3.   document.autoSumForm.quote_total.value = ((total_car_lic * 1) + (adminfee * 1)).toFixed(2);
no problem, but it will not add the
Expand|Select|Wrap|Line Numbers
  1. document.autoSumForm.car<? echo $num; ?>_lic.value
together at all.

Example here
Aug 2 '10 #1
0 1510

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

Similar topics

0
by: descds | last post by:
OK im prety much a newbie at PHP but it has me hooked. Im writing a comment system for one of our modules on phpnuke. Its all going very well, well should i say WAS going very well :) Ok all...
3
by: otto | last post by:
i need to read a variable in a javascript and translate it to a form in html the javascript variable is: <SCRIPT LANGUAGE='JavaScript'>RF2N('Total');</script> and i need to put that...
2
by: Scott Collens | last post by:
Hi all, My page is causing a javascript error. The page is test.aspx and contains a form tag: <form id="theform" runat="server"> Because I have several user controls on the page each of...
1
by: | last post by:
Any help would be greatly appreciated. I'm trying to loop through my child forms.I've seen the "for...each" loop to do this somewhere but can't find it now. I'm thinking storing the form names in...
4
by: dschruth | last post by:
Hello. Can anybody solve this problem? I am using a server-side language (PERL) to *try* to POST data to a HTTPS login script that doesn't have a standard "submit" button. The form appears...
3
by: hispidey | last post by:
Due to a firewall issue I am unable to have the client side form access the server the CGI is located on within our network. Is there a way to have the form send the user information to a...
5
by: therjs | last post by:
i am trying to submit the form multipple times within a loop, if i have an alert() coded, it works, but, when i take the alert() out, it only does the submit the last time through the loop.
4
by: just.an.imbecile | last post by:
I have searched alot for this and cannot find an answer. I have a simple form, and when it submits, I have it posting the data. I have a simple function to loop through and print out all my form...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
6
by: davibugi | last post by:
Hi people please help me out with this code cant find any person who has done it before. I want my calculations to be done without posting to another page. On change on the entered amount the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.