I'm stuck guys, please take 2 seconds and help me if you can.

I have a 2 forms: a site search and a web search. How can I point the form in the right direction after a selection is made and is submitted. So if they choose web search, it posts to web_search.php etc... I've seen this done on several sites and even this one, but I can't figure out how to do it.

Can someone point me in the right direction to solve my dilema?

    I've done this where submit actually calls javascript which has the logic and calls the appropriate page. I build up a string with the url?id=xxx&data=yyy&name=888 etc and put that into the location.

    Check out the menu at www.propertyinvestor.co.nz. It's a variation of the treemenu which is floating around here and at weberdev but shows how I use javascript to control a submit. In this case it's because I need 2 actions.

    good luck

    Sarah

      The easiest way would be to use two buttons. Consider this code.. (note <<< means print the following until the word "ENDFORM" is encountered. This is not a commonly used thing in PHP).

      <?php

      function PrintForm()
      {
      global $PHP_SELF;
      print <<< ENDOFFORM
      <form name="form1" method="post" action="$PHP_SELF">
      <input type="submit" name="Submit" value="button1">
      <input type="submit" name="Submit2" value="button2">
      </form>
      ENDOFFORM;
      }
      if (isset($HTTP_POST_VARS["Submit"]))
      print "Button 1 was pressed";
      else if (isset($HTTP_POST_VARS["Submit2"]))
      print "Button 2 was pressed";
      else
      PrintForm();

      ?>

      Or you can always use a radio button / dropdown and thet the program figure out what to do with it depending on what was selected. Just to sum things up, it IS possible to use multiple buttons in a form. Just access it by $HTTP_POST_VARS["ButtonNAME"]; this will return the button "value" from the HTML code.

        With a selection box you need to check for 2 values, so im trying this but getting an error when checking the second filed. Any help is great.

        <?
        IF (!IsSet($first))
        {
        ?>

        <form name=form1 method=post action=" <? echo "$PHP_SELF"; ?>">
        <input type=text name=query size=10>
        <select name=1>
        <option name=Search>Search</option>
        <option name=Search2>Search2</option>
        </select>
        <input type=submit value=send>
        </form>

        <?
        }
        elseif($first == "send""1") //needs to check 2 values
        {

        if (isset($HTTP_POST_VARS["Search"]))
        Header("Location: *");

        else if(isset($HTTP_POST_VARS["Search2"]))
        Header("Location: *");

        else
        print("error");

        }
        ?>

          How can I check the <select> in the else if? Am I doing this right? Help needed.

            Write a Reply...