Solved

Redirect search function to 2 separate pages

Posted on 2014-03-16
3
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

631 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