[Javascript] Print the contents of a variable into the source
Flavio Gomes
flavio at economisa.com.br
Fri Aug 20 14:33:16 CDT 2004
Laurent, check this variable:
document.location.search
It's use may improve you function.
--
Flavio Gomes
flavio at economisa.com.br
Laurent Muchacho escreveu:
>Hi
>
>>From what I get you need to pickup the value from the querystring is that
>right
>If that is what you want to do then it's pretty easy
>this is your url results.php?kbps=1500
>
>in ASP you will use
>dim myVar : myVar = request.querystring("kbps")
>response.write myVar
>
>in javascript there is no object that let you that but you write your own
>
>function QueryString(param){
> var loca = document.location.href;
> if(loca.indexOf('?' + param + '=')>-1 || loca.indexOf('&' + param +
>'=')>-1){
> var qString = loca.split('?');
> var keyVal = qString[1].split('&');
> for(var i=0;i<keyVal.length;i++){
> if(keyVal[i].indexOf(param + '=')==0){
> var val = keyVal[i].split('=');
> return val[1];
> }
> }
> return false;
> }else{
> return false;
> }
>}
>
>then you can do something like this
>
>var myVar = QueryString("kbps");
>document.write (myVar)
>
>there is an examples pages
>
>http://www.be-lovely.co.uk/querystring/index.html
>
>Laurent
>
More information about the Javascript
mailing list