views:

26

answers:

2

Hi all,

I have a problem and i need some help please. I have this page with a parameter http://www.webxpress.com/landingpage.asp?label=CSU...

Now in this page i have 3 buttons with the following links:
www.webxpress.com/button1.asp
www.webxpress.com/button2.asp
www.webxpress.com/button3.asp

All i want is to add the parameter in the button links (depending on the parameter in the url)... For example: from www.webxpress.com/button1.asp the link comes www.webxpress.com/button1.asp?label=CSU (this parameter is taken from the url).

Can someone please help me and give me some tips because i do not know from where i should start.

A: 

You can use:

document.location.search

which returns the part of the URL after the ? sign (including the question-mark).

To test that this is what you want, try to navigate with your browser on a page with such parameters, and then type in the address bar of the browser:

javascript:alert(document.location.search)

Then, you can use document.write to write the links with this value at the end:

document.write("<a href='http://.../button1.asp" + document.location.search + "'>button1 link</a>");

Rene Zammit
A: 

You can use document.location.search as the previous comment suggested and extract the part you are interested in. Afterwards you can iterate over every link in the page with document.links and update them.

For example:

dl = document.links;
for(i = 0, len = dl.length; i < len; i++) {
  dl[i].href = dl[i].href + '&label=CSU";
}
mhitza
Good idea, though i want this to be dynamic... the parameter in the url is not going to be the same... It changes from now and then...
Rene Zammit
Well you can update that in the JavaScript code from your server side script, no?
mhitza