Solved

Redirect search function to 2 separate pages

Posted on 2014-03-16
3
205 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
paypal ipn url 5 57
Cookie not unsetting 7 19
how to use a switch statement with heredoc 11 23
How to obtain the string from a PHP StdObject ? 6 20
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
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.

777 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