notonurnelly Posted July 18, 2006 Share Posted July 18, 2006 Hi All,I have a list box that is populated directly from an ever growing database feeder table. This works fine,The feeder table has the followign structureCustomerID CustomerName CustCategory1 Airtours Tourist Industry2 MacDonanlds Food IndustryThe listbox is found on a form, once submitted the main value (CustomerName) from the list box is entered into another database tableWhat I also need to do is extract the CustCategory of the selected and place this into a variable on the click event of the listbox.I then want to automatically populate another textfield on the form with this variable to be submitted into the database.Here is my cod efor the list box. <?php $conn = db_connect(); $query_client = "SELECT * FROM tblClients ORDER BY CustomerName ASC"; $result_client = sql_return($query_client); $result_client = mysql_query($query_client); ?> <td width="27%" valign="bottom"> <div align="left"> <?php print "<SELECT NAME=CustomerName>"; print "<OPTION>Please Select....</OPTION>"; while($client_info = mysql_fetch_array($result_client)) { $CustomerID=$clent_info['CustomerID']; $CustomerName=$client_info['CustomerName']; $CustCategory=$client_info['CustCategory']; echo $CustomerID; print "<OPTION value='$CustomerID'>$CustomerName</OPTION>"; } print "</SELECT><br><br>"; ?> $conn = db_connect(); is in an include file and works fine.Many thanks in advance.Jamie Quote Link to comment https://forums.phpfreaks.com/topic/14926-getting-listbox-to-populate-a-text-field-based-on-selected-value/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.