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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:23:05+00:00 2026-06-01T07:23:05+00:00

For my shopping cart I’m using a bit of javascript to update my select

  • 0

For my shopping cart I’m using a bit of javascript to update my select menu for a product amount to add to cart. It works great on updating on the fly depending on the stock left of a particular combination of ‘S’ in ‘Red’. Though I’m trying to limit this select list of only 5, even if more then 5 is reported. Here is what I have thus far to rewrite the drop-down list:

<input type="hidden" id="store_product_stock" class="store_product_stock" />
<select name="item_qty" id="item_qty">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
</select>
<script>
$(function() {
  $('#store_product_stock').change(function() {
    // get the new stock level
    var stock = $(this).val();
    // remove existing dropdown options
    $('#item_qty').empty();
    // add dropdown options again
    for (var i=1; i <= stock; i++) {
      $('#item_qty').append('<option value="'+i+'">'+i+'</option>');
    }
  });
});
</script>
  • 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-06-01T07:23:06+00:00Added an answer on June 1, 2026 at 7:23 am

    can you not just force 5 when stock is over 5 like:

    var stock = $(this).val();
    if(stock > 5){
      stock = 5;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup a shopping cart price rule of 10%. If I add a
I want to create shopping cart without using session variable to avoid load on
Any good cfml Shopping Cart app? Tried using one? What's your experience with it?
I'm using a shopping cart script from a tutorial I came across a while
I have a virtual shopping cart using sessions (sessions stored in the DB). I
I am implementing a shopping cart for my website, using a pseudo-AJAX Lightbox-esque effect.
I'm creating a shopping cart using google checkout api. I what to submit the
I am implementing a shopping cart in iOS. I am using a UINavigationController to
I want to setup a simple shopping cart using PHP, only 2 items, I
I'm making a shopping cart for my website. When an user add something into

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.