/    Sign up×
Community /Pin to ProfileBookmark

script to calculate subtotals and totals based on bullets or checkbox input…

I’m looking for a javascript to calculate input from the user based on either check boxes or bullets (doesn’t matter) in the following manner:

Group 1
Question 1 (bullets to mark 1 through 5)
Question 2 (bullets to mark 1 through 5)
Question 3 (bullets to mark 1 through 5)
Question 4 (bullets to mark 1 through 5)
Question 5 (bullets to mark 1 through 5)
subtotal (group 1) (let’s say 11)

Group 2
Question 1 (bullets to mark 1 through 5)
Question 2 (bullets to mark 1 through 5)
Question 3 (bullets to mark 1 through 5)
Question 4 (bullets to mark 1 through 5)
Question 5 (bullets to mark 1 through 5)
subtotal (group 2) (let’s say 7)

Grand Total (18)

I’ve searched around and I’ve found a few that come close, but they only work with I.E. I just need something simple to work with both Netscape and I.E.

Thanks a lot!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@securityauthorMar 01.2004 — To give you an idea, I'm looking for something like this:

http://javascript.internet.com/calculators/checkbox-calculator.html#source

with subtotal capability (to figure out not just the grand total but to indicate the subtotal in each group) and that works w/netscape.

Thanks again...
Copy linkTweet thisAlerts:
@oleragMar 02.2004 — I can get some sample code to you but first you must

answer several questions..

1. Are these "checkbox" groups static? By that, will there

[b]always[/b] be a specific qty in each group and are there a

specific qty of groups?

2. What do you mean by "bullet"? Do you really mean

"radio group"? If so, are these groups to be checkboxes

or radio groups?
Copy linkTweet thisAlerts:
@securityauthorMar 02.2004 — 
  • 1. Are these "checkbox" groups static? By that, will there

    always be a specific qty in each group and are there a

    specific qty of groups?


  • There are about 10 groups, with maybe 5 or so questions in each group. The scale is 0-5 or 0-10 for each question, and unlike a rating scale more than one question can have the same response, they even call all equal 0 if the person responds in the negative to each question.

  • 2. What do you mean by "bullet"? Do you really mean

    "radio group"? If so, are these groups to be checkboxes

    or radio groups?


  • Yes, radio groups. (oops :-) ) each group of radio buttons will belong to one question, and the subtotal of each group will be calculated based on the total for that group. Then the total of the subtotals will be calculated.

    I really appreciate your help!!!
    Copy linkTweet thisAlerts:
    @oleragMar 02.2004 — Then it sounds as if its a static approach. I'm kinda tied-up

    today but I should be able to get you something by this

    evening that'll mix/match your sub-groups with checkboxes /

    radio groups and indicate what has been chosen.

    I'll stop there for now as you apparently want to do some

    calculations with these selections but haven't giving the

    specific requirements. Don't worry about it - we can get to

    that in "phase 2".
    Copy linkTweet thisAlerts:
    @securityauthorMar 02.2004 — Hi olerag,

    Here's more information........


    0-Never 1-Rarely 2-Occasionally 3-Regularly 4-Often 5-Very Often

    Group 1

    1. question 1

    2. question 2

    3. question 3

    4. question 4

    5. question 5

    Total _____

    Group 2

    1. question 1

    2. question 2

    3. question 3

    4. question 4

    5. question 5

    Total _____

    Group 3

    1. question 1

    2. question 2

    3. question 3

    4. question 4

    5. question 5

    Total _____

    Grand total _____

    There are a total of 24 groups. Each question can be answered by either selecting a radio button 0-5 or entering 0-5 into a textbox. (I'm not sure which would be easier from a coding POV)

    The subtotal should be calculated as indicated, and the grand total made up of all the subtotals at the bottom. All of this should be able to be submitted via a form on the website. The rest of the textbox's and various other information I have under control, but this baffles me...

    Olerag, I appreciate your help more than I can express!!! Take your time, this isn't urgent, I really appreciate this!
    Copy linkTweet thisAlerts:
    @oleragMar 02.2004 — Attached is a sample that provides 3 groups; each group

    contains 3 checkboxes and 2 radio groups. The qty of the

    objects, per group, nor the qty of groups matters so you can

    add/remove what you like. Nor will any of the JS code

    need alterations.

    What will require editing is the amount of objects you need to

    add - this is all straight html. As you adjust, you [b]must[/b]

    adhere to the naming convention employeed, especially for

    the check/radio objects. Also, to derive the calculated values,

    edit the "value" parameter of each object as desired.

    I await your next set of questions....?

    [upl-file uuid=75831e4b-ac00-4e78-ac9e-1de2a6dbc213 size=6kB]questiondemo.txt[/upl-file]
    ×

    Success!

    Help @security spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...