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

Thread: Submit Method

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post

    Submit Method

    When you use a form and submit it the URL bar changes to what the submitted values are. So can anyone explain how to use this?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    When you use a form and submit it the URL bar changes to what the submitted values are.
    Not necessarily. If you use
    Code:
        <form action="somepage.php" method="post">
    the method=post means the data is sent "behind the scenes".

    Only if you use method=get (or omit the method, in which case it defaults to get) will you see the form field values in the QUERY STRING. The query string is everything after the question mark in the URL.

    Note that *ONLY* form fields that are NAMED will be sent, whether by get or by post.

    Posted data can't be used by HTML pages. It must be used by server-side code that can receive it properly.

    Data sent in the querystring can be seen by JavaScript:
    Code:
        var querystring = location.search; // gives everything from ? onward
        var querystring = location.search.substring(1); // omits the ?
    So, then, it is simply a matter of PARSING the query string. And this has been discussed many times in this forum. It's almost identical to parsing document.cookie excepting that the separator character is & instead of ; and there is no space after each &.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    sherlockturtle (10-12-2011)

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    so i can refer to it by using this var querystring?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Yes, but now how do you find out what it *MEANS*?

    Did you follow my point about the parallel to cookies?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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