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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:18:08+00:00 2026-05-13T11:18:08+00:00

On my website, user’s are allowed to filter games by Genre. When a user

  • 0

On my website, user’s are allowed to filter games by Genre. When a user chooses a genre from the select box and hits submit, the page uses GET to see what the filter was. Now the filter works fine, the problem is that the select box’s selection goes to the default one (Which says “All”.)

I want it so that after a user submits their filter request, the select box will keep that selection after the page reloads.

There’s only one way I could think of to do this but it would require adding in PHP into every option there is. Are there any simpler ways to go about doing this with PHP or jQuery?

  • 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-13T11:18:09+00:00Added an answer on May 13, 2026 at 11:18 am

    Assuming you’re doing a full form submit the selected option is only going to be available to the server-side code, once it gets back to the client to use jQuery you won’t have that (unless you try to use cookies before the form submit, but bleh).

    I’d use PHP in the option tag and echo selected="selected" if the option matches up with the selected option.

    If you want to avoid a lot of duplicated code why not do something like this:

    <select name="test">
    <?php
    $options = array(1 => 'Option 1', 2 => 'Option 2', 3 => 'Option 3');
    foreach ($options as $key => $value) { 
       echo '<option value="' . $key . '"' . ($key == $_GET["test"] ? ' selected="selected"' : '') . '>' . $value . '</option>';
    } ?>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing website where user submit credentials using ajax,php and using POST method and
I'm creating a user-based website. For each user, I'll need a few MySQL tables
I once knew a website where the user could generate the little W3C valid
Say a user is browsing a website, and then performs some action which changes
On a website if I have a form where the user can input some
On my website I want a small flash banner which the user can activate
I've developed my website that checks if the user is registered and creates a
I have an website. When the user is logged the session details will loaded.
I have an asp.net website that allows the user to download largish files -
i want something like this the user enter a website link i need check

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.