473,385 Members | 1,838 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,385 software developers and data experts.

JS Calculation Not Functioning

I've got some code that is supposed to calculate some values on a form and generate a total. It seems like it should work but it's definetly not, I am getting objected expected errors from the line(~26) with the onChange event, but I can't see that anything is missing.
Any help is appreciated.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>IOCC</title>
  3. <script> 
  4. <!--
  5. function InvoiceTotal(form)
  6.     {
  7.     var a = (form.#tickets.value != '') ? parseFloat(form.#tickets.value) : 0; if (isNaN(a)) a = 0;
  8.     var b = (form.adprice.value != '') ? parseFloat(form.adprice.value) : 0; if (isNaN(b)) b = 0;
  9.     var c = (form.chprice.value != '') ? parseFloat(form.chprice.value) : 0; if (isNaN(c)) c = 0;
  10.     var d = (form.chtickets.value != '') ? parseFloat(form.chtickets.value) : 0; if (isNaN(d)) d = 0;
  11.     var total = (a * b) + (c * d);
  12.     form.T_amt.value = total.toFixed(2);
  13.  
  14. } -->
  15.  </script>
  16. </head>
  17. <body>
  18. <FORM method="post" action="/randompathtononexistentscript.php">
  19. <label><input type="hidden" name="adprice" value="35" id="adprice"></label>
  20. <label><input type="hidden" name="chtickets" value="0" id="chtickets"></label>
  21. <label><input type="hidden" name="chprice" value="0" id="chprice"></label>
  22. <TR><TD ALIGN=left COLSPAN="2"><p>&nbsp;</p>
  23.   <p>&nbsp;</p></TD>
  24. </TR>
  25.  
  26. <TR><TD ALIGN=left><FONT FACE="Arial" SIZE="1">Number of Tickets</FONT></TD><TD ALIGN=left><label><INPUT NAME="#tickets" TYPE="TEXT" value="0" SIZE="4" id="#tickets" onChange="InvoiceTotal(this.form);"/></label>
  27.  
  28.  
  29. <TR><TD ALIGN=left><FONT FACE="Arial" SIZE="1">Purchase Amount </FONT></TD><TD ALIGN=left><font size="-1" face="Arial">$</font><label><INPUT NAME="T_amt" TYPE="TEXT" ID="T_amt"></label>  <FONT FACE="Arial" SIZE="1"><br></label>
  30.   </FONT></TD></TR><TR><TD ALIGN=left COLSPAN="2">&nbsp;</TD></TR>
  31.  
  32.  
  33. <TR><TD ALIGN=center VALIGN=middle><INPUT NAME="submit button" TYPE="SUBMIT" VALUE="Submit">
  34.  
  35. </FORM></TD></TR></TABLE>
  36. </TD></TR></TABLE>
  37.  
  38. </body>
  39. </html>
  40.  
Oct 17 '07 #1
1 1063
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

I think the # is causing the problem. Replace it with 'NoOf' or something similar instead.
Oct 18 '07 #2

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

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
1
by: georgewbaba | last post by:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <script type="text/javascript"> function addpath(obj ,vari){ ...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
5
by: =?Utf-8?B?amVsbGU3OQ==?= | last post by:
Hi, I want to use a difficult Excelsheet as source for my calculation in a ASP.NET (C#) page. I have 5 input fields on my ASP.NET page and when I press the submit button I want to put these...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.