javascript - take specific items from a string and set in other look -


i have javascript pages , return in array, link want, example:

in array "linkstoopen" ->

game.php?page=fleet&galaxy=7&system=3&planet=4&planettype=1&target_mission=16 

and have others

game.php?page=fleet&galaxy=1&system=10&planet=10&planettype=1&target_mission=16 

i want take array

galaxy = x system = x planet = x 

i have window.location open items in array, want take array things mentioned before, , set here

set galaxy = x above system = x above planet = x above  game.php?page=fleet3&mission=16&galaxy=[here]&system=[here]&planet=[here]&planettype=1&speed=100&metal=0&crystal=0&deuterium=0&usedfleet=lgbkbagcbwvkbggmbwr3bvvlzqnjzqnjzqnjzqnjzqnjzpv7sd==&holdingtime=1 

and open link new values in window.location

someone can how value of every system=x, galaxy=x, planet=x?

i think can alone rest :s

thx

edit:

i through array links, set split in &, in new array use indexof catch lines system, galaxy, planet, think lot of move, there easy way?

use regular expressions.

var link = "game.php?page=fleet&galaxy=7&system=3&planet=4&planettype=1&target_mission=16"; var galaxy = link.match( /&?galaxy=(\d)/ )[1]; var planet = link.match( /&?planet=(\d)/ )[1]; var system = link.match( /&?system=(\d)/ )[1]; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -