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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:23:09+00:00 2026-06-15T03:23:09+00:00

I am searching for a producuct using 4 select boxes, using jQuery I populate

  • 0

I am searching for a producuct using 4 select boxes, using jQuery I populate each box using an ajax call. This all works, however I would now like to use a predetermined search criteria (so it already knows which selected options to use) to populate.

e.g.
Product Source (Fresh, Frozen)
If Fresh is selected then a list depended on this option is populated in the next select box.
Product type(Fruit…)
Product (Apples…)
Colour(Red..)
Etc

Then a stock search is completed using the selected product, so in this case it would be Fresh fruit apples red which may give an id =5.

That works fine, but now I would like to pass Product Source,Product type,Product,Colour into the search and it would populate the select boxes and there other options.
The problem I have is I use on change events on the select boxes to trigger the ajax which fire before the next is loaded.

I hope this makes sense :S

     $("#form_model").change(function(){
    var val = $(this).val();
    if (val != '')
   populateStockItems($("#form_cat").val(),$("#form_sup").val(),val);                  
})

  function  populateStockItems(proid,suppid,modelid){
    var datain ={
    'ProdCode':proid,
    'SuppCode':suppid,
    'Range':modelid
};
getAjax('stockSearch',datain,function(data){

    if(data.result=="success"){             
        var catcbb = $("#form_item");
        catcbb.selectmenu('enable');
        catcbb.empty();
        catcbb.append($('<option></option>').attr("value", '').text(''));
        $.each(data[0].items, function () {
            catcbb.append($('<option></option>').attr("value", this.itemCode).text(this.itemDescription));
        });
        if (data[0].items.length ==1)
            catcbb.get(0).selectedIndex = 1
        catcbb.trigger("change");
    }
    else
    {

    }
})
 }

EDIT- It searches for a product fine, but I now need to prepopulate the filters using a known product, I have all the filter vals.
I think I will do one select at a time and ‘wait’ for the box to be populated through ajax.

  • 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-15T03:23:10+00:00Added an answer on June 15, 2026 at 3:23 am

    This is what I did,
    Set the default value of the select boxes to something random and never used e.g. hhg&hg43
    If the value of that select box = hhg&hg43 then the ajax query had not completed.

    var control =$('#form_cat');
        if(control.first().val()=='hhg&hg43')
            waitForStock(control)
        if(control.first().val()!='hhg&hg43')
        {
            control.val(ProductGroupCode);
            control.trigger("change");
            populateStockSuppliers(control.val());
        }
        else if (control.first().val()=='hhg&hg43'){
            alert('Error getting category');
        }
    
     function waitForStock(control){
    for ( var i=0;i>20 ;i++) 
    {
        if(control.val()!='hhg&hg43')
            return;
        window.setTimeout(waitForStock, 300);
    } }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We call wcf svcs (not ours) and we're using gets for searching a product
Searching around I haven't found any recent answers to this question. The other answers
Searching for values that uses the same value Example SELECT Name, UnitPrice, Quantity, Color
Searching here I found that this question was already asked , but I think
Hi all i am using Google Custom search API $search_query = Amazon+Bestsellers+Rank:+200+in+Health+and+Beauty; $amazon_url =
I have added a Bundled Product in Magento programmatically, using all the options /
In one of my latest projects I use Solr 1.4 for searching products.However I
When searching Amazon using their API is there a way to separate out hardcover,
I've been searching for a solution to this problem for a few days now
I am currently using Irony as part of my searching system and I have

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.