SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Nov 2003
    Location
    here
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Make form submit GET query string rather than POST variables

    Hi all, is it possible to have a form submit values to the query string rather than sending the POST array? I haven't tried to do this before so am a little confused.

    Also, is it possible to have a select box actually change the page when it's selected?

    For example:

    Code:
    <SELECT NAME="textsearchfield" CLASS="dropdown"">
    <option value='-1'>Search where</option>
    <option value='header( Location:index.php?search=allfields)'>All fields</option>
    </SELECT>
    So when someone changes the select menu from "Search where" to "all fields" it goes to the URL i've shown there...I have seen it before just I am not sure how it was done.

    Thanks a lot.
    Cristiano

  2. #2
    SitePoint Evangelist sysice's Avatar
    Join Date
    Oct 2004
    Location
    Hackettstown, NJ
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will submit to index.php with search=allfields or whatever other options you put in the select box.

    Code:
    <FORM action="index.php" method="get">
    <SELECT NAME="search" onchange="this.form.submit();" CLASS="dropdown"">
    <option value="">Search where</option>
    <option value="allfields">All ields</option>
    </SELECT>
    </FORM>

  3. #3
    Non-Member
    Join Date
    Nov 2003
    Location
    here
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks..

    One more question:

    With this method, it replaces the query string.

    For example if the current url is bla.php?bla1=bla1 and the user chooses search=allfields i want the new url to be bla.php?bla1=bla1&search=allfields rather than bla.php?search=allfields..

    Thanks

  4. #4
    SitePoint Evangelist sysice's Avatar
    Join Date
    Oct 2004
    Location
    Hackettstown, NJ
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could user the variable $_SERVER['QUERY_STRING'] to preserve the current query string.

    Code:
    <FORM action="index.php?<?=$_SERVER['QUERY_STRING']?>" method="get">
    <SELECT NAME="search" onchange="this.form.submit();" CLASS="dropdown"">
    <option value="">Search where</option>
    <option value="allfields">All ields</option>
    </SELECT>
    </FORM>
    Though, I'm not sure if the QUERY_STRING already has the new value in it, in which case you would need to have to do a bit more work.


Bookmarks

Posting Permissions

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