Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:47:46+00:00 2026-05-29T07:47:46+00:00

I have a calculation form which gets its values from a JSON var shirtsJSON

  • 0

I have a calculation form which gets its values from a JSON

    var shirtsJSON = [
        {"pattern": "Delta Adult S/S 5.2oz", "basePrice": 5.68,
            "sizes": {"s-xl": 0, "xxl": 0.84},
            "colors": {"white": 0, "athletic": 0.12, "color": 0.23},
            "numColors": {"1-2": 0, "3-4": 1.60, "5-6": 3.18, "7-8": 4.81, "9-10": 6.39},
            "deductions": {"de48pp": 0, "de72pp": .9, "de96pp": 1.35, "de144pp": 2.37, "de288pp": 2.65},
            "oneLocation": {"onelocnone": 0, "oneloc12": 3.28, "oneloc34": 5.41, "oneloc56": 7.52, "oneloc78": 9.69, "oneloc910": 11.80}, 
            "twoLocation": {"twolocnone": 0, "twoloc12": 3.28, "twoloc34": 5.41, "twoloc56": 7.52, "twoloc78": 9.69, "twoloc910": 11.80},
            "threeLocation": {"threelocnone": 0, "threeloc12": 3.28, "threeloc34": 5.41, "threeloc56": 7.52, "threeloc78": 9.69, "threeloc910": 11.80},
            "fourLocation": {"fourlocnone": 0, "fourloc12": 3.28, "fourloc34": 5.41, "fourloc56": 7.52, "fourloc78": 9.69, "fourloc910": 11.80}},

        {"pattern": "Delta Adult S/S 6.1oz", "basePrice": 6.68,
            "sizes": {"s-xl": 0, "xxl": 0.84},
            "colors": {"white": 0, "athletic": 0.12, "color": 0.23},
            "numColors": {"1-2": 0, "3-4": 1.60, "5-6": 3.18, "7-8": 4.81, "9-10": 6.39},
            "deductions": {"de48pp": 0, "de72pp": .70, "de96pp": 1.25, "de144pp": 2.47, "de288pp": 2.55},
            "oneLocation": {"onelocnone": 0, "oneloc12": 3.28, "oneloc34": 5.41, "oneloc56": 7.52, "oneloc78": 9.69, "oneloc910": 11.80}, 
            "twoLocation": {"twolocnone": 0, "twoloc12": 3.28, "twoloc34": 5.41, "twoloc56": 7.52, "twoloc78": 9.69, "twoloc910": 11.80},
            "threeLocation": {"threelocnone": 0, "threeloc12": 3.28, "threeloc34": 5.41, "threeloc56": 7.52, "threeloc78": 9.69, "threeloc910": 11.80},
            "fourLocation": {"fourlocnone": 0, "fourloc12": 3.28, "fourloc34": 5.41, "fourloc56": 7.52, "fourloc78": 9.69, "fourloc910": 11.80}},

Then I have the final results here

            $('#48pp').html("Per Piece : " + currency + getMoney(totalPrice));
            $('#72pp').html("Per Piece : " + currency + getMoney(totalPrice));
            $('#96pp').html("Per Piece : " + currency + getMoney(totalPrice));
            $('#144pp').html("Per Piece : " + currency + getMoney(totalPrice));
            $('#288pp').html("Per Piece : " + currency + getMoney(totalPrice));

I want it to subtract the values from the deductions JSON I tried doing this:

$('#72pp').html("Per Piece : " + currency + getMoney(totalPrice - shirtsJSON.deductions[0].de72pp));

but it didn’t work and I can’t seem to figure it out. Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:47:47+00:00Added an answer on May 29, 2026 at 7:47 am

    I think the [0] is in the wrong place – try it after shirtsJSON instead of deductions:

    $('#72pp').html("Per Piece : " + currency + getMoney(totalPrice - shirtsJSON[0].deductions.de72pp));
    

    instead of:

    $('#72pp').html("Per Piece : " + currency + getMoney(totalPrice - shirtsJSON.deductions[0].de72pp));
    

    This is because shirtsJSON is an array, whereas deductions not.

    EDIT:

    Quick example of a loop to retrieve multiple deductions. This assumes that each deductions part contains the same pieces of information each time (e.g. they all contain 48pp, 72pp etc.)

    for(i = 0; i < shirtsJSON.length; i++) {
        $('#72pp').html("Per Piece : " + currency + getMoney(totalPrice - shirtsJSON[i].deductions.de72pp));
        ...etc...
    }
    

    Notice how the i has replaced the 0 in shirtsJSON[0]. You would need to change your code slightly so that it .appended (which adds to the end of whatever’s in that element), instead of using .html (which overwrites whatever’s in that element).

    EDIT 2:

    Here’s a link that you might find helpful: http://blog.xkoder.com/2008/07/10/javascript-associative-arrays-demystified/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an order form on which I use the jQuery Calculation Plugin to
I have a non-modal child form which opens up from a parent form. I
I have the following text input on a budget calculator form which displays the
I have a fairly expensive array calculation (SpectralResponse) which I like to keep to
I have a method, which uses random samples to approximate a calculation. This method
i have html form with textarea in which i paste some XML, for example:
I'm new to MDX and have a problem regarding filtering out values from a
I have an ASP.NET form that takes input from a user. There's a Submit
i have an user form which he has to fill before moving on to
I have simple web application (asp.net - ajax) I have a web form which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.