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 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing Values or Content using Params Using Javascipt

    Here is the script:

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function getParams() {
    var idx = document.URL.indexOf('?');
    var params = new Array();
    if (idx!= -1) {
    var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
    for (var i=0; i<pairs.length; i++) {
    nameVal = pairs[i].split('=');
    params[nameVal[0]] = nameVal[1];
    }
    }
    return params;
    }
    params = getParams();
    // End -->
    </script>


    Heres the address it uses when the form is submitted:


    http://www.example.com/test.html?qua...ress=1002+road etc....


    Heres the Problem:


    <SCRIPT LANGUAGE="JavaScript">
    name = unescape(params["name"]);
    address = unescape(params["address"]);
    </SCRIPT>

    SCRIPT OUTPUT:
    Name = new+guy
    Address = 1002+road


    I need the output to be:


    OUTPUT:
    Name = new guy
    Address = 1002 road


    so it needs to change the "+" for a "space". Any help or comments is greatly apreciated.

    ~Isaac Lloyd~

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    This should work....

    name = unescape(params["name"]);
    var regEx = /\+/gi;
    name = name.replace(regEx," ");

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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