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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:27:22+00:00 2026-05-14T01:27:22+00:00

I have written a cascading drop down list using JQuery. The code that I

  • 0

I have written a cascading drop down list using JQuery. The code that I have written works; the cascading list when changed, updates the cascaded-to list. BUT when I navigate away from the page and then press the back button on the browser, the CASCADED drop down list loses its values. Here is my code (the category list populates the products list when changed):

<select id="CategoryList" onchange="CategoryList_OnChange()">
    <option value="" selected="selected"></option>
    <option value="1" selected="selected">Food</option>
    <option value="2" selected="selected">Toys</option>
    <option value="3" selected="selected">Books</option>
</select>

<select id="ProductList"></select>

<script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
    function CategoryList_OnChange() {
        var selected = $('#CategoryList').val();
        if (selected != null && selected != '') {
            $.getJSON('SelectList/ProductList/' + selected, function(selectList) {
                $('#ProductList option').remove();
                $.each(selectList, function(index, value) {
                    $('#ProductList').append("<option value='" + value.Value + "'>" + value.Text + "</option>");
                });
            });
        }        
    }
</script>

Is there any way to keep the ProductList populated even when navigating away from the page? My understanding of how browsers work is that they are meant to keep state of the page, even when navigating away.

I know that I could merely put code in

$(document).ready(function() { ... });

which will explicitly call the onchange method but this has the disadvantage of making a call to the website when in fact I want the page to maintain the EXISTING state.

Please 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-14T01:27:22+00:00Added an answer on May 14, 2026 at 1:27 am

    Why should a browser keep the state that resulted from js manipulation. Most browsers won’t.

    You could try using the cookies library and save what (if any) Category was selected. When the user later returns to the page and hasn’t cleared the cookies in the meantime you can read the value out from the cookie and automatically issue the $.getJSON request to “refill” the product list

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

Sidebar

Related Questions

I have written this code in JavaScript and works perfectly fine when I include
I have written a very simple CTE expression that retrieves a list of all
This following code snippet works fine using jQuery1.2.3, but it doesn’t work with latest
I have written the following code. I know that a higher order function is
I have written a code that draws grids and a triangle inside one grid
I have written a site in Prototype but want to switch to jQuery. Any
I have written following code for the client of RMI. But getting java.rmi.ConnectException: Connection
I have written a small code, but found something amazing. I have a class
I have written some JavaScript code that will read from the Google Maps API
I have written some code in a UIImage category that takes a UIImage (self)

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.