passing parameter to url via <a> tag int html
I have in a variable (var lan= urlParam('language')
) the selected language.
I want to pass this language as parameter (without using PHP) in a url in an "a
" tag, like this:
<a href="http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode开发者_高级运维=lan">
but it doesn't work.
I am waiting for your answers. Thank you a lot.
Your url is inside a string, so it won't put the value of your variable, but just the string "lan".
Give an ID to your link, so you can take it and change its url with javascript.
<a id="foo" href="http://hotelscombined.sitewish.gr/HotelNameSearch.aspx">
Then, with JS
document.getElementById('foo').setAttribute('href', 'http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode=' + lan);
If I understand correctly, you can just use document.write to print the link and add the variable as the language parameter.
<script type="text/javascript">document.write("<a href=\"http://hotelscombined.sitewish.gr/HotelNameSearch.aspx?languageCode=" + lan + "\">link description</a>");</script>
精彩评论