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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:30:36+00:00 2026-05-31T19:30:36+00:00

I’m trying to keep the list of values from drop-down selections when the browser

  • 0

I’m trying to keep the list of values from drop-down selections when the browser back-button is click after the form has been submitted. I tried using Ben Alman’s bbq jquery, but failed to get things working. Here’s what I’ve been trying. Please help.

Many thanks in advance.

HTML

<form action="something.py" id="formName">
    <table id = "tabName">
        <tr>
            <th>Name</th><th>Number</th>
        </tr>
        <tr>
            <td>
                <select id="myname" name="myname">
                    <option value="a">a</option>
                    <option value="b">b</option>
                    <option value="c">c</option>
                </select>
            </td>
            <td>
                <select id="mynumber" name="mynumber">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                </select>
            </td>
        </tr>
    </table>
    <input type="submit" value="submit" />
</form>

JQuery:

var selected_value = [];
$('#mynumber').change(function() {
    var name = $('#myname').val();
    var number = $('#mynumber').val();

    $("#tabName tr:last").before("<tr><td>" + name + "</td><td>" + number + "</td></tr>");
    selected_value.push(name);
});

$('#formName').submit(function() {
    $.bbq.pushState({
        values: selected_value
    });
    //return false;
});

$(window).bind("hashchange", function(e) {
    var values = $.bbq.getState("url");
    if (selected_value === values) {
        $(this).addClass("current");
    } else {
        $(this).removeClass("current");
    }
});
  • 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-31T19:30:37+00:00Added an answer on May 31, 2026 at 7:30 pm

    My solution (without cookies or localStorage) based on location.hash:

    function addRow(name, number){
        $("#tabName tr:last").before("<tr><td>" + name + "</td><td>" + number + "</td></tr>");
    }
    
    $(function(){
        if(location.hash){
            var rows = location.hash.substr(1).split(';');
            for(var i = 0; i < rows.length; i++){
                var row = rows[i].split(',');
                if(row.length == 2){
                    addRow(row[0], row[1]);
                }
            }
        }
    
        $('#mynumber').change(function() {
            var name = $('#myname').val();
            var number = $('#mynumber').val();
            location.hash = location.hash + (location.hash ? ';' : '') + name + ',' + number;
            addRow(name, number);
        });
    });
    

    I think it does what you have asked for – if not, please give me some feedback in comments.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.