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

  • Home
  • SEARCH
  • 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 9290097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:20:12+00:00 2026-06-18T20:20:12+00:00

I have some javascript sorting my ul, alphabetically a-z or z-a. It works fine

  • 0

I have some javascript sorting my ul, alphabetically a-z or z-a. It works fine on page one, but if there is more than one page it ignores the list on page 2 etc.

So, instead of using javascript to sort the li’s, I want to pass the selection back to the page’s query and reload

here’s my script, most of which is redundant now.

var select = document.getElementById('organise');

        $('#organise').change(function() {

            if(select.value === 'A') {

                $('.recipeTable li').sortElements(function(a,b){

                    var aText = $.text([a]);
                    var bText = $.text([b]);

                    return aText.toLowerCase() > bText.toLowerCase() ? 1 : -1;
                });

            } else {

                $('.recipeTable li').sortElements(function(a,b){

                    var aText = $.text([a]);
                    var bText = $.text([b]);

                    return aText.toLowerCase() > bText.toLowerCase() ? -1 : 1;
                });

            }

        });

So I want to detect the selected dropdown value (either A or Z) and pass that into the url and reload. I’m stuck ;-?

Rich 🙂

  • 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-18T20:20:13+00:00Added an answer on June 18, 2026 at 8:20 pm

    I am not sure this is the best way to approach the problem, and maybe you should elaborate what doesn’t work with your pagination. In any case, you can achieve what you need to do by doing something like this (explaination in the code comments):

    var queryString = {};
    
    // Get the previous query string with a little help from PHP
    // this shouldn't be a problem since you are already using PHP
    // for your project.
    queryString = <?php json_encode( $_GET ); ?>;
    
    $('#organise').change( function() {
    
        // Set the sort property of the object to the value of the select.
        queryString.sort = $(this).val();
    
        // jQuery will help you serialise the JSON object back to
        // a perfectly valid query string (you may want to escape
        // characters)
        newQueryString = $.param( queryString );
    
        // Append the new query string
        window.location = newQueryString;
    
    });
    

    This function will properly check if you already have any query string and preserve that; also, if the user changes the select multiple times, it will not add up several query strings.

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

Sidebar

Related Questions

i have some javascript roll over code that works fine in firefox but when
I have some javascript to direct the page to a new url but I
I have some javascript applying changes to some elements and a function loading more
I have some JavaScript code that works in IE containing the following: myElement.innerText =
I have a page with more than 200 links with this kind of formatting.
i have some javascript in the head of a page that controls an image
I have some JavaScript which is changing an image correctly but once it has
I have some Javascript files I would like to minify and combine into one
I have some javascript objects that I'd like to collaboratively manipulate, but am having
I have done some research about Javascript sorting algorithms performance comparison, and found unexpected

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.