Need help with dynamic select form

Hi, I need help setting up a dynamic form. The form will be a reservation type form. I have a single table, which I will post below. What I am looking to do is choose a month from a select box and then have it populate another select box with the available dates.

Here is my table info from mysql…

CREATE TABLE `daterange` ( `RID` int(5) NOT NULL auto_increment, `DEND` date NOT NULL, `MONTH` varchar(50) NOT NULL, `DATE` varchar(50) NOT NULL, `SITE` varchar(50) NOT NULL, `PRICE` varchar(10) NOT NULL, `STATUS` varchar(1) NOT NULL default 'A', `FNAME` varchar(50) NOT NULL, `LNAME` varchar(50) NOT NULL, `ADDR1` varchar(50) NOT NULL, `ADDR2` varchar(50) NOT NULL, `CITY` varchar(50) NOT NULL, `STATE` varchar(2) NOT NULL, `ZIP` varchar(5) NOT NULL, `PHONE1` varchar(3) NOT NULL, `PHONE2` varchar(3) NOT NULL, `PHONE3` varchar(4) NOT NULL, `EMAIL` varchar(50) NOT NULL, PRIMARY KEY (`RID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=83 ;

Here is a sample mysql dump…

INSERT INTO `daterange` VALUES(1, '2011-05-15', 'May 2011', '5/15-5/22/11', 'Carterville Pond/Adirondack', '$2625.00', 'N', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); INSERT INTO `daterange` VALUES(2, '2011-05-22', 'May 2011', '5/22-5/29/11', 'Carterville Pond/Adirondack', '$2625.00', 'A', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); INSERT INTO `daterange` VALUES(3, '2011-05-29', 'May 2011', '5/29-6/5/11', 'Carterville Pond/Adirondack', '$2625.00', 'A', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');

Finally, here is a php form that I started to develop but it only has a single select box, which works but I wanted another select box that will filter the list down a little…
[php] <?
// script to display all the Available Reservations in the daterange table

// connection information
$hostName = “my_host”;
$userName = “my_user”;
$password = “my_pass”;
$dbName = “my_db”;

// make connection to database
mysql_connect($hostName, $userName, $password) or die(“Unable to connect to host $hostName”);

mysql_select_db($dbName) or die(“Unable to select database $dbName”);

// Select all the fields in all the records of the daterange table
$query = “SELECT *
FROM daterange
WHERE DEND > DATE(NOW())
AND STATUS=‘A’
ORDER BY RID, DATE, SITE”;

$result = mysql_query($query);

// Determine the number of reservation dates
$number = mysql_numrows($result);

// Create drop-down menu of reservation dates

print “<font size=“3” face=“Arial”>Select Reservation Date:
<form action=“test.php” method=“post”>
<select name=“RID”>
<option value=”">Choose One";

for ($i=0; $i<$number; $i++) {
$RID = mysql_result($result,$i,“RID”);
$DATE = mysql_result($result,$i,“DATE”);
$SITE = mysql_result($result,$i, “SITE”);
$PRICE = mysql_result($result,$i, “PRICE”);
print “<option value=”$RID">$DATE, $SITE, $PRICE";
}

print "

<font size=“3” face=“Arial”>First Name: <input type=“text” name=“FNAME” size=“50” maxlength=“50” tabindex=“1"
”;

print "

Last Name: <input type=“text” name=“LNAME” size=“50” maxlength=“50” tabindex=“2"
”;

print "

Address Line 1: <input type=“text” name=“ADDR1” size=“50” maxlength=“50” tabindex=“3"
”;

print "

Address Line 2: <input type=“text” name=“ADDR2” size=“50” maxlength=“50” tabindex=“4"
”;

print "

City: <input type=“text” name=“CITY” size=“50” maxlength=“50” tabindex=“5"
”;

print "

State (abbrev.): <input type=“text” name=“STATE” size=“2” maxlength=“2” tabindex=“6"
”;

print "

Zip Code: <input type=“text” name=“ZIP” size=“5” maxlength=“5” tabindex=“7"
”;

print "

Contact Phone Number: (<input type=“text” name=“PHONE1” size=“3” maxlength=“3” tabindex=“8"”;
print ")<input type=“text” name=“PHONE2” size=“3” maxlength=“3” tabindex=“9"”;
print "-<input type=“text” name=“PHONE3” size=“4” maxlength=“4” tabindex=“10"
”;

print "

Email: <input type=“text” name=“EMAIL” size=“50” maxlength=“50” tabindex=“11"
”;

print “

Payment Method: <select name=“PM”>
<option value=”">Choose One
<option value=“Visa”>Visa
<option value=“Mastercard”>Mastercard
<option value=“Discover”>Discover";

print "

Credit Card Number: <input type=“text” name=“C1” size=“4” maxlength=“4” tabindex=“12"”;
print " <input type=“text” name=“C2” size=“4” maxlength=“4” tabindex=“13"”;
print " <input type=“text” name=“C3” size=“4” maxlength=“4” tabindex=“14"”;
print " <input type=“text” name=“C4” size=“4” maxlength=“4” tabindex=“15"
”;

print “

Expiration Month: <select name=“EXM”>
<option value=”">Choose One
<option value=“January”>January
<option value=“February”>February
<option value=“March”>March
<option value=“April”>April
<option value=“May”>May
<option value=“June”>June
<option value=“July”>July
<option value=“August”>August
<option value=“September”>September
<option value=“October”>October
<option value=“November”>November
<option value=“December”>December";

print "

Expiration Year: <select name=“EXY”>
<option value="">Choose One
<option value=“2011”>2011
<option value=“2012”>2012
<option value=“2013”>2013
<option value=“2014”>2014
<option value=“2015”>2015
<option value=“2016”>2016
<option value=“2017”>2017
<option value=“2018”>2018
<option value=“2019”>2019
<option value=“2020”>2020";

print "

Security Code (3 or 4 digits): <input type=“text” name=“CSC” size=“4” maxlength=“4” tabindex=“16"
”;

print “

<input type=“submit” value=“Book Now!”
name=“submit”>”;

print " <input type=“reset” value=“reset”
name=“reset”>";

// Close the database connection
mysql_close();

?>[/php]

Any help would be gladly appreciated.

-Bob

Hi Bob,

A bit confused here and I can’t seem dive to the solution. Anyway,

What I have understood is that you would want to auto populate the COMBO BOX named as 'EXM" based on your selection at combo box “EXY”. Am I right?

Cheers.

Sponsor our Newsletter | Privacy Policy | Terms of Service