jQuery setting variables from url string -


i have url string http://www.example.com/?chicken?toast

and want able store values after each of ? characters.

i have working getting last ?value - cant seem store first...

code works last ?value is:

window.lastvalue = window.location.href.substring(window.location.href.lastindexof('?') + 1); 

how can store first also?

so firstvalue = chicken , lastvalue = toast

update - how can store totalval flattening array? so, if array ["chicken", "toast"] need flattened string "." before each item in array - if array ["chicken", "toast"] become ".chicken.toast" - if array ["chicken"] become ".chicken" // thanks

cheers,

this give array of values want:

var r = window.location.href.split("?"); r.shift(); console.log(r); 

if there 2 values, can use extract them:

var val1 = r.shift(); var val2 = r.shift(); 

here's version gives .chicken result:

var r = window.location.href.split("?"); r[0]=''; var totalval = r.join('.'); 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -