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
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Query String Question

    I have a simple form that passes a string from Page1 to Page2.

    Everything is working fine except that if the input has spaces, the spaces are displayed on Page2 as '+' signs.

    How can I modify the code to make the spaces not display as '+' signs?

    Page1
    Code:
    <html>
    <head>
    <title></title>
    </head>
    
    <body>
    
    <form name="myform" method="get" action="page2.html">
    <input name="input1">
    <input type="submit">
    </form>
    
    </body>
    </html>
    Page2
    Code:
    <html>
    <head>
    <title></title>
    
    <script LANGUAGE="JavaScript">
    <!--
    function decodeSearchString() {
       var nameValue = new Array();
       var searchStr = unescape(location.search.substring(1));
       if (searchStr) {
           var formElement = searchStr.split("&");
           var tmpArray = new Array();
           for (k = 0; k < formElement.length; k++) {
                tmpArray = formElement[k].split("=");
                nameValue[tmpArray[0]] = tmpArray[1];
           }
       }
       return nameValue
    }
    
    var srchData = decodeSearchString();
    //-->
    </SCRIPT>
    </head>
    
    <body>
    
    <script>document.write(srchData.input1);</script>
    
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    string = string.replace(/\+/g, ' ');
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #3
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Where do i out that in the code?

  • #4
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Wherever you want the '+' character replaced with the ' ' character.
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).


  •  

    Posting Permissions

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