SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 29th, 2003, 09:56 PM
szms szms is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 107 szms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Problem with unchecking checkbox

Please take a look of this code. I am having problem when I try to uncheck any item. I keeps the cost for unchecked item. Can you please help me to solve this. Thank you.

<html>

<head>
<title></title>
<script type="text/javascript">
<!--
var total = new Number();
function showTotal()
{
var tax = total * (5/100);
var finalTotal = total + tax;
alert("Your total cost is: $" + finalTotal.toFixed(2) + "");
return false;
}
//-->
</script>
</head>

<body>



<form action="">
<p>
<input type="checkbox" onclick="total += 0.59"/> Apple (59 cents each) <br/>
<input type="checkbox" onclick="total += 0.49"/> Orange (49 cents each)<br/>
<input type="checkbox" onclick="total += 0.39"/> Banana (39 cents each)<br/><br/>
<input type="submit" name="submit" value="Submit" onclick="showTotal()"/>
</p>
</form>



</body>

</html>

Reply With Quote
  #2  
Old July 29th, 2003, 10:00 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Problem with unchecking checkbox

you need to change the onclicks to onchange used to call a function and in the function calculate the total on the fly.

Reply With Quote
  #3  
Old July 29th, 2003, 10:02 PM
szms szms is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 107 szms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Problem with unchecking checkbox

Thank you for your help. Little bit code may help more.

Reply With Quote
  #4  
Old July 29th, 2003, 10:14 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Problem with unchecking checkbox

the forum is not to have people write your code for you it's for you to get help when you can't figure out how to do something. If someone totally writes every function you ever need you aren't going to learn very much and will be still asking for the same help in a year. Do a search on google for - onChange javascript and you'll get a host of tutorials on how to implement this property basically it's onchange(yourfunction();) and in your function you need to check which boxes are checked and calculate the total right then.

Reply With Quote
  #5  
Old July 29th, 2003, 11:44 PM
szms szms is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 107 szms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Problem with unchecking checkbox

Hey.. I am kind of new in Java script so it would be great if someone help me with the code. Thank you.

Reply With Quote
  #6  
Old July 29th, 2003, 11:53 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Problem with unchecking checkbox

I wasn't trying to be mean but I have been a memeber of baords like these for about 7-8 yrs (although they sure look better than they used to) and eventually what happens to people who just keep asking for someone else to do the whole thing for them is that everyone stops helping them. Bottom line, I told you what was wrong, you're simply adding to your total every time the check box is clicked and there is no code to remove that addition so it doesn't work correctly.

you need to take some time and read a little about how to build a function and callit with and event handler.


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Problem with unchecking checkbox


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway