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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:37+00:00 2026-05-23T11:02:37+00:00

I’m using a PHP framework Codeigniter that uses segment based urls like http://www.mydomain.com/age/11/name/john/color/red instead

  • 0

I’m using a PHP framework Codeigniter that uses segment based urls like http://www.mydomain.com/age/11/name/john/color/red instead of the usual querystrings lijke http://www.mydomain.com/index.php?age=11&name=john&color=red.

How do I grab the value of the age key from the url using Javascript/jQuery?

After grabbing the value 11 I will pass it into a jQuery object when an event is fired.

$( "#searchdistance_slider" ).slider({
        range: "min",
        value: 5,
        min: 0.5,
        max: 10,
        slide: function( event, ui ) {
            $( "#search_distance" ).val(ui.value + " miles");
            window.location.replace("http://www.domain.com/" + age); 
            /* passing the value of age into URL to redirect to */
        }
    });

UPDATE

  • The key/value pairs can change position, and the number of key/value pairs in the URL are not fixed
  • I need to grab the value within Javascript because the user uses a slider to change a particular value, say the age, and the new value 20 from the slider will be use to redirect the user to http://www.mydomain.com/age/20/name/john/color/red
  • 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-23T11:02:37+00:00Added an answer on May 23, 2026 at 11:02 am

    You could try using the jQuery URL parser plugin.

    Use the .segment(n) call to search the URL path for "age", and grab the next one which should contain the age value you’re looking for.

    Or try the .fsegment(n) method if age is always in the same position.

    Or use .segment() with something like:

    var parts = $.url(your_url).segment();
    var params = [];
    for (var i=0; i<parts.length/2; i++) {
       params[parts[2*i]] = parts[2*i+1];
    }
    var age = parseInt(params['age']);
    

    (I’m sure there’s a prettier way to do that though.)

    If you only want the age part, you don’t have to do all that stuffing into a dictionary. Just exit the loop early when you’ve found the key you want.

    If you want to reconstruct the path with a changed age, try something like:

    var parts = $.url(your_url).segment();
    var newpath = '';
    for (var i=0; i<parts.length/2; i++) {
      if (parts[2*i] == 'age') {
        newpath += '/age/' + (parseInt(parts[2*i+1]) + 42); // put your age modifiy
                                                            // code here
      } else {
        newpath += '/' + parts[2*i] + '/' + parts[2*i+1];
      }
    }
    alert(newpath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I would like to count the length of a string with PHP. The string
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
For some reason, after submitting a string like this Jack’s Spindle from a text

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.