Click to See Complete Forum and Search --> : Transfering value between pages


difrad76
07-22-2004, 12:30 PM
Hello

I am trying to transfer a value from one page to another like so.

file:///G:/Dima/HTML/Merit/companies2.html?sm=1

Now, I need to read sm variable and depending on what it is, load a page in the floating frame onload().

How can I do this ?

Thanks.

crh3675
07-22-2004, 01:10 PM
<script>

String.prototype.trim=function(){
return this.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}


function getVars(){
var qs=document.location.search.substr(1).trim();

if(qs.length>0){
var qa=qs.split("&");

for(i=0;i<qa.length;i++){
parts=qa[i].split("=");
newvar="var "+parts[0]+"=\""+parts[1]+"\";";
eval(newvar)
}

}

}

</script>


<body onload="getVars()">
</body>


Will load any query string variables in to Javascript variables. Note that until the function runs, your variables will be "undefined"