# JAVASCRIPT: get variable value from URL

**URL:** <https://forum.kirupa.com/t/javascript-get-variable-value-from-url/210586>\
**Category:** web dev\
**Created:** [December 20, 2006, 5:26am UTC](https://forum.kirupa.com/t/javascript-get-variable-value-from-url/210586 "2006-12-20T05:26:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [December 20, 2006, 5:26am UTC](https://forum.kirupa.com/t/javascript-get-variable-value-from-url/210586/1 "2006-12-20T05:26:28Z")

</div>

I have been trying to make a dynamic map getting the address from the URL with google maps api. i have been literally searching for tutorials and reading documentation and could never do it. i finally found this tutorial:  
[http://www.developer.com/lang/jscript/article.php/3615681](http://www.developer.com/lang/jscript/article.php/3615681)

and i think i kinda got it already. the only thing i have to do now is pass the variable value from a link to javascript.

Lets say i have this link:

```auto

<a href="test.php?address=100+Main+St">link</a>

```

How can I retrieve that in javascript?

I see you can declare a variable like this:  
var address = “100 Main St”;

But I can’t declare the variable just like that, I need to get the value from the URL. Im also using php, if that helps.

Thanks in advance,

Leo
