Jump to content

Loading multiple forms on the same page based on user selection?


Solarpitch

Recommended Posts

Hey Guys,

not quite sure what this is called as you can probably guess from the subject header! But what I am trying to do is...

On my home page I have a form to search by keyword. Below that I want to have an Advanced search option but dont want to display that form on the page untill the user selects the option "Advanced Search."

When they select that I want the advanced form to load onto the home page. Now, I've kinda seen sites that have done this with a url that looks something like:

http://www.example.com/home.php

http://www.example.com/home.php/mode=advanced --> When advanced option is selected

I would love some help on how to achieve this,

Thanks Guys.
You could do something like the following. Use an if...else on the actual search page to determine which form was submitted. ie isset($_POST['simple_search') or isset($_POST['advance_search']
[code]<?php if(isset($_GET['mode']) && $_GET['mode'] == 'advance'){ ?>
<a href="form.php">simple Search<a>
<h1>Advance Search</h1>
<form method="post" action="">
<input type="text" name="search" /><br />
<input type="text" name="criteria" />
<input type="submit" name="advance_search" value="Search" />
</form>
<?php  } else { ?>
<a href="form.php?mode=advance">Advance Search<a>
<h1>Simple Search</h1>
<form method="post" action="">
<input type="text" name="search" />
<input type="submit" name="simple_search" value="Search" />
</form>
<?php } ?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.