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 6372593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:15:31+00:00 2026-05-25T01:15:31+00:00

I am working on fixing a website which is coded by someone else. Codes

  • 0

I am working on fixing a website which is coded by someone else. Codes are really messy so I am afraid I can’t post it all here but I believe I provided enough information for you to see what could be wrong. Because at this point I am lost.

1. We get min and max limits

parent_id = '<?php echo $parent_id; ?>';
api = '<?php echo $api; ?>';
    $.getJSON('getlimits.php', {'id': ""+parent_id+"", 'api': ""+api+""}, function(data) {
        // Loop and assign Json (returned value) to our limit variables
        $.each(data, function(key, val) {
            min_limit = key;
            max_limit = val;
        });
    });

getlimits.php OutPut:

{"10":"15000"}

2. We check the limits

amount = $('#quantity', this).val();

console.log(amount + ' - Max : ' + max_limit + ' Min : ' + min_limit);

if ( amount < min_limit) {
    displayError("You can't order less than " + min_limit + " units",2000);
    return false;
}
else if ( amount > max_limit ) {
    displayError("You can't order more than " + max_limit + " units.",2000);
    return false;
}

Logged Results;

800 - Max : 15000 Min : 10

I typed 800 units. It shouldn’t give any error but I am getting following error;

You can’t order more than 15000 units.

I am truly lost. Log shows correct values, getlimits.php returns correct values but if & else if conditions are not working.

I will be glad if anyone could help me out with this problem.

Thank you in advance.

  • 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-25T01:15:32+00:00Added an answer on May 25, 2026 at 1:15 am

    amount is not an integer when you grab it through .val().

    So adjust this line:

    amount = $('#quantity', this).val();
    

    to

    amount = parseInt($('#quantity', this).val());
    

    As pointed out by Dennis, you will have to parseInt the values you are grabbing from the JSON as well. (min_limit and max_limit).

    As Dennis also pointed out, you should add 10 as a second parameter to parseInt to make sure it parses as a decimal number.

    So:

    $.each(data, function(key, val) {
        min_limit = parseInt(key,10);
        max_limit = parseInt(val,10);
    });
    
    amount = parseInt($('#quantity', this).val(),10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on fixing a bug in someone's code and I can't figure out
I am currently working on fixing a c# codebase which does not have a
I am working (or fixing bugs) on an application which was developed in VS
I am working on fixing a website that doesn't work in the new release
Working with python interactively, it's sometimes necessary to display a result which is some
I'm working on a website where the frontend is powered by AJAX, interacting with
I am working on fixing a bug to my google chrome extension for Gmail.
I am working on fixing older code for my job. It is currently written
I am working on fixing a bug in VB that is giving this error.
I'm working on a video game which requires high performance so I'm trying to

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.