Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-15-2002, 01:47 PM   PM User | #1
winlineau
Banned

 
Join Date: Jun 2002
Location: Australia
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
winlineau is an unknown quantity at this point
Unhappy 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 =-
winlineau is offline   Reply With Quote
Old 06-15-2002, 03:14 PM   PM User | #2
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
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>
JohnKrutsch is offline   Reply With Quote
Old 06-16-2002, 03:40 AM   PM User | #3
winlineau
Banned

 
Join Date: Jun 2002
Location: Australia
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
winlineau is an unknown quantity at this point
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
winlineau is offline   Reply With Quote
Old 06-16-2002, 02:55 PM   PM User | #4
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
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"){
JohnKrutsch is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:22 AM.


Advertisement
Log in to turn off these ads.