I have a script that does some calculations and returns a Google Maps direction drawn on a map with the API.
I will keep my question easy and use this example:
var a;
var b;
var c;
function DoMath(){
//random number 1-20 for example
a = random(1,20);
b = random(1,20);
c = a + b;
}
So now the function makes a sum with random numbers. I want it like this:
When the users types after the site url /5/14 that the JavaScript sets a to 5 and b to 14 and uses those numbers instead of randoms. I also want the script to use randoms when there is nothing given in url.
Questions:
- How do I read url?
- How do I set the var to the url value?
- How can I make it so you could give only
aorbor both in the url?