You are here: javascript querystring « PHP Programming Language « IT news, forums, messages
javascript querystring

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация