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

Help with function

breagan1
I get an object expected error with this partial code. I'm trying to get it to add the checkbox totals into the text field. Any ideas?

Expand|Select|Wrap|Line Numbers
  1.  <script type="text/javascript" language="JavaScript">
  2. function TotalCheckedValues() {
  3. var total = 0;
  4. if(document.Fee.1.checked == true) { total += parseFloat(document.Fee.1.value); }
  5. if(document.Fee.2.checked == true) { total += parseFloat(document.Fee.2.value); }
  6. if(document.Fee.3.checked == true) { total += parseFloat(document.Fee.3.value); }
  7. if(document.Fee.4.checked == true) { total += parseFloat(document.Fee.4.value); }
  8. var ts = new String(total);
  9. if(ts.indexOf('.') < 0) { ts += '.00'; }
  10. if(ts.indexOf('.') == (ts.length - 2)) { ts += '0'; }
  11. document.Fee.T.value = ts;
  12. }
  13. </script>
Expand|Select|Wrap|Line Numbers
  1.  </head>
  2. <body>
  3. <center>
  4.  
  5.  
  6. <FORM name="Fee" Submit="return checkrequired(this)" METHOD="POST" ACTION="$website/cgi-bin/conference.cgi"> 
  7.   <tr align="left">
  8.     <td>
  9.      <style type="text/css">
  10.       <!--
  11.        .button {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt}
  12.        .textarea {  font-family: "MS Sans Serif"; font-size: 9pt; width: 350px}
  13.        .input {  width: 195px}
  14.       -->
  15.     </style>
  16.                 <b>Registration Fees:
  17.  
  18.                 Which do you want?<br>
  19.                 <input type="checkbox" name="1" value="350" onClick="TotalCheckedValues()"> 3 Days = 350.00
  20.  
  21.                 <input type="checkbox" name="2" value="300" onClick="TotalCheckedValues()"> 2 Days = 300.00
  22.  
  23.                 <input type="checkbox" name="3" value="150" onClick="TotalCheckedValues()"> 1 Day  = 150.00
  24.  
  25.                 <input type="checkbox" name="4" value="125" onClick="TotalCheckedValues()"> Spouse Meal Package = 125.00
  26.  
  27.                 <input type="text" name="T" readonly size="5"> = Total Fee To Be Mailed
  28.  
  29.  
  30. </FORM>
Jun 14 '07 #1
3 1303
r035198x
13,262 8TB
Hi and welcome to TSDN. You posted the question in the wrong forum.
Java != Javascript. So I've moved it to the Javascript forum.
Jun 14 '07 #2
epots9
1,351 Expert 1GB
where does it say your error is?

and
[HTML]<FORM name="Fee" Submit="return checkrequired(this)" METHOD="POST" ACTION="$website/cgi-bin/conference.cgi"> [/HTML]

should be:

[HTML]<FORM name="Fee" onSubmit="return checkrequired(this)" METHOD="POST" ACTION="$website/cgi-bin/conference.cgi">
[/HTML]

and where is the function checkrequired()?
Jun 14 '07 #3
I just figured it out. I renamed the checkboxes with letters instead of numbers (same in the function code) and now it works. Thank you.

Code: ( javascript )
<script type="text/javascript" language="JavaScript">
function TotalCheckedValues() {
var total = 0;
if(document.Fee.a.checked == true) { total += parseFloat(document.Fee.a.value); }
if(document.Fee.b.checked == true) { total += parseFloat(document.Fee.b.value); }
if(document.Fee.c.checked == true) { total += parseFloat(document.Fee.c.value); }
if(document.Fee.d.checked == true) { total += parseFloat(document.Fee.d.value); }
var ts = new String(total);
if(ts.indexOf('.') < 0) { ts += '.00'; }
if(ts.indexOf('.') == (ts.length - 2)) { ts += '0'; }
document.Fee.T.value = ts;
}
</script>



Code: ( html4strict )
</head>
<body>
<center>


<FORM name="Fee" onSubmit="return checkrequired(this)" METHOD="POST" ACTION="$website/cgi-bin/conference.cgi">
<tr align="left">
<td>
<style type="text/css">
<!--
.button { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt}
.textarea { font-family: "MS Sans Serif"; font-size: 9pt; width: 350px}
.input { width: 195px}
-->
</style>
<b>Registration Fees:

Which do you want?<br>
<input type="checkbox" name="a" value="350" onClick="TotalCheckedValues()"> 3 Days = 350.00

<input type="checkbox" name="b" value="300" onClick="TotalCheckedValues()"> 2 Days = 300.00

<input type="checkbox" name="c" value="150" onClick="TotalCheckedValues()"> 1 Day = 150.00

<input type="checkbox" name="d" value="125" onClick="TotalCheckedValues()"> Spouse Meal Package = 125.00

<input type="text" name="T" readonly size="5"> = Total Fee To Be Mailed


</FORM>
Jun 14 '07 #4

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

Similar topics

7
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: Stef Mientki | last post by:
I'm making special versions of existing functions, and now I want the help-text of the newly created function to exists of 1. an extra line from my new function 2. all the help text from the old...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
1
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.