Solved

Redirect search function to 2 separate pages

Posted on 2014-03-16
3
208 Views
Last Modified: 2014-03-16
I'm trying to set up a search function for a property website where you search for either 'Buy' or "Let'

If you click on Buy I want to redirect to uksearch.php  and if you click let you go to uksearchlet.php

I can't figure out how to redirect to separate page depending on the button clicked, hope someone else does!

The info from the hidden info buttons needs to be sent over in the URL.

Here's the code i'm using at the moment which goes the same page regardless of which button you click


   <form name="form1" method="get" action="uksearch.php">
    
    
      <div class="searchbut">      <input type="submit" name="saleorRent" id="button" value="Buy"  style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;">
      
      
      
      <input type="submit" name="saleorRent" id="button" value="Let"  style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;"></div>
      <input name="area" type="text" class="searchinput" id="area">
     
     
      
      <input name="intsearch" type="hidden" id="intsearch" value="250">
      <input name="max" type="hidden" id="max" value="99999999999999">
      <input name="intsearch" type="hidden" id="intsearch" value="GBR">
    </form>

Open in new window

0
Comment
Question by:BrighteyesDesign
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39933056
   <form name="form1" method="get" action="uksearch.php">
    
    
      <div class="searchbut">      
<input type="submit" name="saleorRent" id="button" value="Buy"  style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;">
      
      
      
      <input type="submit" name="saleorRent" id="button" value="Let"  onclick="javascript:form1.action='uksearchlet.php'" style="width: 60px; height: 54px; border: 0px; font-family: Georgia, Times, serif; font-size: 25px; outline: 0px; padding: 0px;background: url(images/search-rent.jpg) no-repeat; cursor: pointer;"></div>
      <input name="area" type="text" class="searchinput" id="area">
     
     
      
      <input name="intsearch" type="hidden" id="intsearch" value="250">
      <input name="max" type="hidden" id="max" value="99999999999999">
      <input name="intsearch" type="hidden" id="intsearch" value="GBR">
    </form> 

Open in new window

0
 

Author Comment

by:BrighteyesDesign
ID: 39933066
You're a superstar, cheers for that
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39933085
A little bit of theory...
http://php.net/manual/en/tutorial.forms.php

The action= attribute of the form tag determines what URL will be requested when the form is submitted.  You can only submit a form to one URL.  But that one URL can call a script that does lots of interesting things.

For example, the action script could look at the value of the submit control and decide whether to transfer control to a Buy or Let script.  Perhaps this transfer of control could happen via a require() statement.  You can have any number of submit control buttons - as many as you would like - and the value associated with the submit control is the same as any value associated with a text input control.

Please post back if you have any questions -- it's a little involved to set up an example but I'll be willing to do so if you need an example.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question