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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:05:37+00:00 2026-05-22T02:05:37+00:00

I have a webpage thats created by javascript injections and one of my pages

  • 0

I have a webpage thats created by javascript injections and one of my pages has a dropdown shown below:

html +="<select name='Sort' id='Sort' onchange='sortSwitch(document.getElementById(\"Sort\")[document.getElementById(\"Sort\").selectedIndex].value);     display(document.getElementById(\"searchQuery\").value);return false;'>\n";  
  html +="<option></option>\n";  
  html +="<option value='4'>Smallest First</option>\n";  
  html +="<option value='5'>Largest First</option>\n";  
  html +="<option value='6'>A-Z</option>\n";  
  html +="<option value='7'>Z-A</option>\n";  
  html +="</select>";  

The dropdown filters the information displayed on the page by passing the selected option to a switch function and another function reloads this information. However, when the javascript page loads again, it starts off with the blank option.

Does anyone know of a good way to remember the last sort selected? For example, if I sort with “Smallest First” and then the page refreshes, the box will show “Smallest First” as apposed to the blank. I know there is an “option selected” attribute, but I need it to be dynamic. I feel like it is something trivial, yet I can’t seem to put my finger on it.

Thanks 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-22T02:05:38+00:00Added an answer on May 22, 2026 at 2:05 am

    Here’s an article on Cookies in JavaScript which contains an explanation of how they work, along with functions to read, write and delete cookies.

    Using those functions you’d get the selected value and write the cookie to save the value like this:

    var select = document.getElementById("Sort");
    var selectedItem = select.options[select.selectedIndex].value;
    createCookie("selectedItem",selectedItem);
    

    then read the cookie to retrieve the value and select the option in the select box, like this:

    var selectedItem = readCookie("selectedItem");
    var select = document.getElementById("Sort");
    select.value = selectedItem;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web site I created that uses Python, HTML, and javascript. The
I have created a web page that has two bars across the top of
I will create a webpage that has a sidebar, and the sidebar will have
I'm writing a webpage that relies on an external javascript file (that I have
I have a AJAX/Javascript intensive webpage and is trying to create a static version
I have created a simple webpage that launches a widget after a button is
I have updated my example My case has two steps: 1) User will select
I have created a form in the user's browser with JavaScript. Later on I
I have created a english to hindi transliteration webpage . There are rules for
I have a WebPage made that is 90% Javascript. All of the WebSite is

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.