I have two drop down lists in my form- catagory and the second one sub-catagory.When user selects a particular catagory corresponding sub-catagory should be displyed in the second drop down list for further user selection.I am using PHP-Mysql in dreamweaver.When i preview the first list is working properly but the second one is not.
when i test my record set using test value i am getting the current subcatagories.How is it possible to autopopulate the drop down list?

Subcatagory-recordset query
SELECT Sub_catagory
FROM subcatagory
WHERE Catagory = 'colname'
ORDER BY Sub_catagory ASC

can you add some code to show us what you have done so far.

Here is a simple and straightforward script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var arrayData = new Array(); 
 
arrayData[0]	= 'ALL|ALL|' 
arrayData[1]    = 'one|sub1|'
arrayData[2]    = 'one|sub2|'
arrayData[3]    = 'one|sub3|'
arrayData[4]    = 'two|sub1|'
arrayData[5]    = 'two|sub2|'
arrayData[6]    = 'three|sub|'
function populateData( name ) { 
	select	= window.document.form.SubCategory; 
	string	= ""; 
		// 0 - will display the new options only 
		// 1 - will display the first existing option plus the new options 
	count	= 0; 
		// Clear the old list (above element 0) 
	select.options.length = count; 
		// Place all matching categories into Options. 
	for( i = 0; i < arrayData.length; i++ ) { 
		string = arrayData[i].split( "|" ); 
		if( string[0] == name ) { 
			select.options[count++] = new Option( string[1] ); 
		} 
	} 
		// Set which option from subcategory is to be selected 
//	select.options.selectedIndex = 2; 
		// Give subcategory focus and select it 
//	select.focus(); 
} 

</script>
<title>Untitled Document</title>
</head>

<body>
<form id="form" name="form" method="post" action="">
        <select name='category' size=1 style="width:120;" 
				onChange='javascript:populateData( this.options[selectedIndex].text )'>
          <option>ALL</option>
          <option>one</option>
          <option>two</option>
          <option>three</option>
        </select>
        <br />
        <br />
        <span class=DefMenuText>Sub-Category:</span><br />
        <select name="SubCategory" size=1 style="width:120;">
          <option>ALL</option>
        </select>
</form>
</body>
</html>

I will post a tutorial soon at http://www.effectivewebdesign.co.nz/tutorial.php

Hope this helps :)

<?php require_once('Connections/databaseconnection.php'); ?>
<?php
mysql_select_db($database_databaseconnection, $databaseconnection);
$query_catagory = "SELECT Catagory FROM catagory ORDER BY Catagory ASC";
$catagory = mysql_query($query_catagory, $databaseconnection) or die(mysql_error());
$row_catagory = mysql_fetch_assoc($catagory);
$totalRows_catagory = mysql_num_rows($catagory);

$colname_subcatagory = "1";
if (isset($HTTP_POST_VARS['catagory'])) {
  $colname_subcatagory = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['catagory'] : addslashes($HTTP_POST_VARS['catagory']);
}
mysql_select_db($database_databaseconnection, $databaseconnection);
$query_subcatagory = sprintf("SELECT Sub_catagory FROM subcatagory WHERE Catagory = '%s' ORDER BY Sub_catagory ASC", $colname_subcatagory);
$subcatagory = mysql_query($query_subcatagory, $databaseconnection) or die(mysql_error());
$row_subcatagory = mysql_fetch_assoc($subcatagory);
$totalRows_subcatagory = mysql_num_rows($subcatagory);
?>


html part....
.......
 <td height="29" align="left" bordercolor="#FFFFFF">Catagory <font color="#FF0033">*</font></td>
        <td height="29" colspan="3" bordercolor="#FFFFFF"> 
          <select name="select" size="1" onChange="MM_validateForm('Buisnessname','','R','Telephone','','NisNum','address','','R');return document.MM_returnValue">
            <?php
do {  
?>
            <option value="<?php echo $row_catagory['Catagory']?>"<?php if (!(strcmp($row_catagory['Catagory'], $row_catagory['Catagory']))) {echo "SELECTED";} ?>><?php echo $row_catagory['Catagory']?></option>
            <?php
} while ($row_catagory = mysql_fetch_assoc($catagory));
  $rows = mysql_num_rows($catagory);
  if($rows > 0) {
      mysql_data_seek($catagory, 0);
      $row_catagory = mysql_fetch_assoc($catagory);
  }
?>
          </select>
        </td>
      </tr>
      <tr> 
        <td align="left" bordercolor="#FFFFFF">Sub Catagory <font color="#FF0033">*</font></td>
        <td height="27" colspan="3" bordercolor="#FFFFFF"> 
          <select name="select2">
            <?php
do {  
?>
            <option value="<?php echo $row_subcatagory['Sub_catagory']?>"<?php if (!(strcmp($row_subcatagory['Sub_catagory'], $row_subcatagory['Sub_catagory']))) {echo "SELECTED";} ?>><?php echo $row_subcatagory['Sub_catagory']?></option>
            <?php
} while ($row_subcatagory = mysql_fetch_assoc($subcatagory));
  $rows = mysql_num_rows($subcatagory);
  if($rows > 0) {
      mysql_data_seek($subcatagory, 0);
      $row_subcatagory = mysql_fetch_assoc($subcatagory);
  }
?>
          </select>
        </td>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.