javascript, asp.net, image with variables

Hi,

I have the following code

        
<a href="http://www.xyz.com" target="_blank">
            <img src="http://www.thesocialreviews.com/images/6Steps.gif" alt="StepsImage" /></a>

Open in new window


What I want to do is in the ahref pass a variable and when the user clicks the image it should go to http://www.xyz.com, this bit is fine but how do i pass a variable in the link.

either as Javascript or HTML

Thanks

R8VI
R8VIAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
What's a "variable in the link"? An additional parameter?

URL's support this by appending a
http://www.xyz.com?myvarriable=myvalue

Whoever receives the request must inspect the query parameters and use them as appropriate.

So, what I understand is that this value isn't available on page load, is something you want to add on 'click', right?

So for that, kust handle the link click event and do the request by hand, which should resemble something like:
<a href="http://www.xyz.com" onclick="return processClick()" target="_blank">
<img src="http://www.thesocialreviews.com/images/6Steps.gif" alt="StepsImage" />
</a>

Open in new window

var myVariable = "abcd";

function processClick(){
    var url = this.href;
    url = url + "?var=" + myVariable; 
    window.location.href = url;
    return false;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.