Jump to content


Photo

Getting Listbox to populate a text field based on selected value


  • Please log in to reply
No replies to this topic

#1 notonurnelly

notonurnelly
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 18 July 2006 - 09:24 AM

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 structure

CustomerID        CustomerName        CustCategory
1                      Airtours                  Tourist Industry
2                      MacDonanlds          Food Industry

The listbox is found on a form, once submitted the main value (CustomerName) from the list box is entered into another database table

What 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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users