Hi,
I am trying to read in a query string from one page and build a link to
another page based on the query string.
Here's the code I am using to read in the query string:
<script "text/javascript">
function getQueryVariabl e(variable) {
var query = window.location .search.substri ng(1);
var vars = query.split("&" );
for (var i=0;i<vars.leng th;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
}
</script>
This works fine.
I can print out the query sting value using document.write:
document.write( getQueryVariabl e("x") );
But when I try to add the query string to a link using document.write
it doesn't work:
document.write( "<a href='prod_requ est.html?id=' &
getQueryVariabl e('x')>Prod | </a>")
I am trying to read in a query string from one page and build a link to
another page based on the query string.
Here's the code I am using to read in the query string:
<script "text/javascript">
function getQueryVariabl e(variable) {
var query = window.location .search.substri ng(1);
var vars = query.split("&" );
for (var i=0;i<vars.leng th;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
}
</script>
This works fine.
I can print out the query sting value using document.write:
document.write( getQueryVariabl e("x") );
But when I try to add the query string to a link using document.write
it doesn't work:
document.write( "<a href='prod_requ est.html?id=' &
getQueryVariabl e('x')>Prod | </a>")
Comment