Results 1 to 8 of 8
Thread: Combine 2 forms into 1
May 25, 2009, 04:28 #1
Combine 2 forms into 1
On my main homepage, I have 2 forms.
The first form only consist of a dropdown box.
When a user selects, New York and hits the "go" button, it will
redirect to mymainpage.com/newyork.php
<form name="navList" onsubmit="return submitForm();"> <b>Select your state</b></font><font face="Arial"><font size="2"> </font> <select name="subMenu"> <option value="home"> </option> <option value="Washington.php"> Washington DC </option> <option value="newyork.php">New York</option> <option value="Alabama.php"> Alabama </option> <option value="Alaska.php"> Alaska </option> <option value="Arizona.php"> Arizona </option> <option value="Arkansas.php"> Arkansas </option> <option value="California.php"> California </option> </select><font size="2"> </font> </font> <input type="submit" value="Go"><font size="2"> </font> </form>
then inside my newyork.php, there are some information about New York.
and some db stuff such as
$result = mysql_query("SELECT * FROM `table` WHERE `city_state` = 'New York'
All that was created a month ago.
However, just recently, I decided to add in a function where user can select the category that they wish to see.
So, that is why I have also added another form,
and this form also consist of only a drop down box.
<form method="POST" action="category.php"><b>Category</b>
//create a single array of options
$opts = array( 'Automobile', 'Apparel','Careers','Consumer goods','Education','Electronics','Food and Beverage','Furniture','General Business','Society');
// Use here to create your form elements
echo '<select name="option">' . PHP_EOL;
foreach ( $opts as $key=>$val )
echo '<option value="'.$val . '">' . $val . '</option>' . PHP_EOL ;
echo '</select>' . PHP_EOL;
<input type="submit" name="submit" value="Go">
Both of the forms works perfectly on THEIR OWN!
They have their separate functions, and separate "submit" buttons.
They go to their own separate php pages.
But, I want to combine both of them into just 1 form, and 1 submit button.
This is so that the user can choose both drop down box value at once.
Example, the user can select "New york" AND "Apparel".
Result: It goes to mymainhomepage.com/newyork.php and shows all the post related to apparel.
How can I do this ?
Thanks a BILLION for your generous support and kind assistance.
May everyone here have a blessed week ahead!