Current location: Hot Scripts Forums » General Web Coding » JavaScript » Simple addition on a web form


Simple addition on a web form

Reply
  #11 (permalink)  
Old 03-14-10, 03:33 PM
JonChuck JonChuck is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for all your help.

<<< referral link removed >>>

Last edited by wirehopper; 03-14-10 at 06:06 PM. Reason: Removed referral link
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #12 (permalink)  
Old 03-14-10, 10:19 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Hello JonChuck,

Your website looks nice.
There is one thing.
When the page first loads, there is a 0 in the "total" input field.
And if you click one of the check boxes a value is displayed.
But if you uncheck the box the "total" input field goes blank instead of going back to 0.

You didn't use the latest Javascript I gave you.
It will function properly if you use this Javascript.
HTML Code:
function add_values()
{
 var value = 0;
 var objs = document.getElementsByTagName("input");
 for(var i=0;i<objs.length;i++)
 {
  var obj = objs[i].type;
  if(obj == "checkbox")
  {
   if(objs[i].checked == true){value += parseInt(objs[i].value);}
   }
  }
 document.getElementById("total").value = value;
 }
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #13 (permalink)  
Old 03-14-10, 10:38 PM
JonChuck JonChuck is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you so much. It is working perfectly now. I had not thought to test it that way, rather than relying on the "reset" button.

Question: Is it a drastic change if I replace the 3 check boxes with a pull-down list numbering, 0 to 5?

I was thinking that this might be cleaner.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #14 (permalink)  
Old 03-15-10, 08:31 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by JonChuck View Post
Thank you so much. It is working perfectly now. I had not thought to test it that way, rather than relying on the "reset" button.

Question: Is it a drastic change if I replace the 3 check boxes with a pull-down list numbering, 0 to 5?

I was thinking that this might be cleaner.
I don't know. You would have to show me what you mean.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect Web Form output derrickfellowes HTML/XHTML/XML 2 04-13-09 12:40 PM
[SOLVED] Simple form validation question macintosh PHP 1 03-29-09 02:31 AM
Problem with FormMail script for simple contact form amang Perl 2 09-21-07 08:59 PM
HELP!! need web form to send as email pfd attachment clg Script Requests 0 02-04-06 04:39 PM
I need HELP with my web form! Softball4Ever CSS 1 07-22-05 08:10 PM


All times are GMT -5. The time now is 07:30 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.