Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Over-writing a javascript total
Old 11-08-2007, 06:53 AM Over-writing a javascript total
Skilled Talker

Posts: 81
Trades: 0
Hi

I have a page with checkboxes. As people select these, a running total is displayed in a little popup,
within an input form name="total" id="total" using
onclick="checkTotal()" adds that value to the total, using

Code:
function checkTotal() {
var total = document.selectboxForm.total;

    var choice = document.selectboxForm['choice[]'];
    var choice1 = document.selectboxForm['choice1'];
    var choice2 = document.selectboxForm['choice2'];

    var sum = 0;

    for (i=0;i<choice.length;i++) {
        if (choice[i].checked)
            sum = sum + parseInt(choice[i].value);
    }

    for (i=0;i<choice1.length;i++) {
        if (choice1[i].checked)
            sum = sum + parseInt(choice1[i].value);
    }

    for (i=0;i<choice2.length;i++) {
        if (choice2[i].checked)
            sum = sum + parseInt(choice2[i].value);
    }

    total.value = sum;
   
}
However, because I don't want them to see their final total till the next page, I was to suspend this totaliser afer about half the checkboxes.

What I would like to do is introduce a new function for the later checkboxes: onclick="checkReport()" which will overwrite the numerical total in the popup with words such as 'is shown on your report page'

I tried something like function checkReport() {
total.value = wordinghere;
}
but that doesn't work.

Any idea how to do this? (It's the value 'total' that needs to be overwritten, not 'finaltotal'. Is it possible to enter non-numerals in a value?

this is what a cutdown version of the checkboxes looks like:
http://ied.gospelcom.net/church-site-designtest1.php

Many thanks

Tony

Last edited by soon; 11-08-2007 at 07:38 PM.. Reason: clarity
soon is offline
Reply With Quote
View Public Profile Visit soon's homepage!
 
 
Register now for full access!
Reply     « Reply to Over-writing a javascript total
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07890 seconds with 12 queries