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 value20from the slider will be use to redirect the user tohttp://www.mydomain.com/age/20/name/john/color/red