Posted by radiox on 10/30/25 11:45
Hi guys,
I have this html file containing:
<html><head>
<script src="variable.js?id=1004"></script>
</head><body></body></html>
I also have the .js file that looks like this
----------------------------------------------------------------------------------------
var id = getQueryVariable("id");
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
var returned = 0;
for (var i=0;i<vars.length;i++)
{
var pair = vars[i].split("=");
if (pair[0] == variable)
{
returned = pair[1];
}
}
return returned;
}
document.write(id);
-----------------------------------------------------------------------------------------
I do a mistake somewhere and I don't get back the value of the id in
the querystring.
I get the value displayed only if i add the querystring at the end of
the html file name in the browser's address line.
It might be a small problem, but I know very little JavaScript so I
require your help.
Thanks in advance
Navigation:
[Reply to this message]
|