Helpful Information
 
 
Category: JavaScript programming
Another Question

!!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 =-

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>

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

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"){










privacy (GDPR)