# Solved: HTML, using a javascript variable in <a href>



## andynic

I want to be able to append a paramter to a url used in a reference tag.

The following works as I wish:
<a href="abcu0026_u003du003cu003etextSlides.html?7">
but I want the "7" to be varialbe, similar to the "onClick" construct below which works:










speedVal is a javascript global variable set to a value between 1 and 15.

When I try
<a href="abcu0026_u003du003cu003etextSlides.html?speedVal">
it presents the URL in the browser as
abcu0026_u003du003cu003etextSlides.html?speedVal

When I use
<a href="abcu0026_u003du003cu003etextSlides.html?"+speedVal>
It presents the URL in the browser as 
abcu0026_u003du003cu003etextSlides.html?

Is there some syntax for the javascript variable that I can use?

Thanks for your help.
Andynic


----------



## Ent

Var Target="window.location='abcu0026_u003du003cu003etextThumbs.html?'" + speedVal;
onclick = Target;


----------



## Big-K

link

slightly simpler


----------



## andynic

Thanks, Ent and Big-K for the replies. 
I ultimately used this syntax:
href="abcu0026_u003du003cu003etextSlides.htmll" onclick="this.href+='?'+speedVal;"
May switch over to Big-K's solution because it mirrors the syntax that I use in the <IMG> tag.


----------



## andynic

Forgot to credit the above syntax to Fang at WebDeveloper.


----------

