Pass a JavaScript variable through a URL redirect

I have a drop down box that uses javascript to change the contents of a google map on select.

I am tracking and storing the drop value as a javascript variable.

I need to use this javascript variable as a URL parameter for a page redirect.

ie <ahref="myredirect.asp?parameter=<JAVASCRIPT VARIABLE HERE>">link</a>

How do i get the javascript variable into the URL string?
LVL 2
AlemusAsked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
Thought sure that would work.  This does (I checked it this time).
<script type="text/javascript">
<!--
document.write('<a href="myredirect.asp?parameter=');
document.write(var1);
document.write('">link</a>');
// -->
</script>

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
Like this?
<a href="myredirect.asp?parameter=
<script type="text/javascript">
<!--
document.write(variable);
// -->
</script>

">link</a>

Open in new window

0
 
AlemusAuthor Commented:
Entered exactly like that yields

myredirect.asp?parameter=<script type=
0
 
srikanthmadishettiCommented:
try use like this

here i used ss as available js variable


<script>
var ss = 1;
</script>
<a href="javascript:window.location='myredirect.asp?parameter='+ss;" >link</a>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.