This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes checkboxes & javascript addition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "checkboxes & javascript addition" Watch "checkboxes & javascript addition" New topic
Author

checkboxes & javascript addition

Patrick Kenyon
Greenhorn

Joined: Dec 11, 2003
Posts: 2
Hello,
I have been watching this forum for some time now, but this is the first time I've ever needed to post a question, because I don't think there is the same question anywhere else. Maybe I just can't find it. Anyway, here is my code. I can not get my value to display into the text input. I'm not sure if it adds or not, however. Hopefully, someone can point out what I did wrong. This is for a fake store for a project I have in school.

I know it has to be something stupid that I did wrong, so I would appreciate any help that is given. I am about ready to cry.
Patrick
[ December 11, 2003: Message edited by: Patrick Kenyon ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
onChange='showTotal' should be
onChange='showTotal()'
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You actually have a lot more problems then that
-Your function does not have a ending }
-You are using the word form instead of inputForm in all of your checkbox validations
-You do not need to update the text field with the total each time you are in an if statement since you have it at the end.
-You do not want to use quotes around your numbers and it acts like a string. It will make your numbers look like this "90" + "210" = "90210"
-You do not want to use nested if statements since it will not pick up all of the checkboxes. You want to use just plain if statements
- Your totals need to use a diferent start number or it is going to keep adding numbers to the total. Means that if a person keeps checking and unchecking the computer can cost a billion dollars.
- You should use onClick instead of onChange since it works better for radio buttons
- You need to add in onload event to put the total in or they can submit the form for free.
-Also when you are calling the function, you need to include ().
You are lucky I am nice today and did the changes for you:
Patrick Kenyon
Greenhorn

Joined: Dec 11, 2003
Posts: 2
Thank You Eric! You are my new best friend! It'd probably be better if I made the changes myself, so that's what I'm going to do. ^_^ Then I'll check yours against mine to make sure I understand what's going on. Thanks again.
Patrick
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: checkboxes & javascript addition
 
Similar Threads
problem in select
have problem with multiple forms on a jsp
pass a variable in the URl
Need to Hide Table inside div:Code is Working Fine in FireFox but Not in IE..Please Help
jquery accordion is causing jquery treeview picker to breakup