...

View Full Version : Another Question



winlineau
06-15-2002, 01:47 PM
!!I NEED HELP!!

At the end of an HTML page, you can sometimes see something like this:

?FirstName=&LastName=&EMail=&Error=&Server=

I want to make a JS that can enterpret THESE EXACT VARIABLES.

I then want it to print EVERY variable on a new line.

HOW CAN YOU DO THIS




P.S. -= I AM 11, Make this simple =-

JohnKrutsch
06-15-2002, 03:14 PM
Something like this ought to do the trick:

<script type="text/javascript">
<!--//
if (location.search){
var vals=location.search.substr(1).split("&");
for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
vals[i][0] = unescape(vals[i][0]);
vals[i][1] = unescape(vals[i][1]);
document.write(vals[i][0]+" => "+vals[i][1]+"<br />");
}
}
//-->
</script>

winlineau
06-16-2002, 03:40 AM
I need to change the script so it can detect if one of the variables is called "EMail"

I have come up with this:
<script type="text/javascript">
<!--//
if (location.search){
var vals=location.search.substr(1).split("&");
for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
vals[i][0] = unescape(vals[i][0]);
vals[i][1] = unescape(vals[i][1]);
document.write(vals[i][0]+" => "+vals[i][1]+"<br />");
if (vals[i][0]="EMail"){
alert("email")
}
}
}
//-->
</script>


BUT IT DOESNT WORK

please help

JohnKrutsch
06-16-2002, 02:55 PM
In your script you do not try to check for "EMail" you assign it the value of "EMail". To check for equality you would use double equal signs like so:

if (vals[i][0]=="EMail"){



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum