Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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>

  • #3
    Banned
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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"){


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •