Here is my take on it, cobbled together with the help of a js wizard
friend of mine:
<?php include("config.inc.php"); //config contains database connection
params ?>
<html>
<head>
<title>Dynamic Dropdown Menus</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
//array of arrays of <select> options corresponding to
//the values in the static menu.
var menus = new Array();
<?php
//get set of names of level 1 categories
$sql="select parent_cat from site_map where site_level = 1";
$link_id = mysql_connect($host, $usr, $pass) or die (mysql_error());
mysql_select_db($database, $link_id); //select database catalog
$parent_cat_result = mysql_query($sql, $link_id) or die (mysql_error());
//return result set to php
$parent_cat_count = mysql_num_rows($parent_cat_result);
//build a option list for js function
//currently this echoes a number for the menu - must be replaced with
parent cat.
$i=0; //start menus[] at zero
while (list ($current_parent) = mysql_fetch_row ($parent_cat_result))
{
//debug//echo "current parent is $current_parent<br>";
$sql="select link_show, child_cat from site_map where parent_cat =
\"$current_parent\"";
$link_id = mysql_connect($host, $usr, $pass) or die (mysql_error());
mysql_select_db($database, $link_id); //select database catalog
$child_cat_result = mysql_query($sql, $link_id) or die (mysql_error());
//return result set to php
echo "menus[$i]=new Array( \n";
$i++;
$child_cat_count=mysql_num_rows($child_cat_result);
$cc=0;
while (list ($link_show, $child_cat) = mysql_fetch_row
($child_cat_result))
{
echo "new Option(\"$link_show\", '$child_cat') ";
$cc++;
if ($cc < $child_cat_count)
{
echo ", \n";
}
else {
echo " \n";
}
}
echo "); \n";
}
?>
Best regards,
Andrew
On Wednesday, September 12, 2001, at 06:59 PM, Jared Mashburn wrote:
> I have tried using "onChange" in my script but have faild to load the
> values of the first drop-down list.
> Can I place an array inside an array. Or is there a better way of doing
> this?
>
> -----Original Message-----
> From: Jason Bell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 12, 2001 4:47 PM
> To: Jared Mashburn; PHP Users
> Subject: Re: [PHP] Dynamic Form
>
>
> PHP does not know what the user has selected in the first drop down.
>
> You can either reload the page with the new value once the user has
> selected the value for the first drop down list, and go from there, or
> use Javascript.
>
>
> ----- Original Message -----
> From: "Jared Mashburn" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, September 12, 2001 3:45 PM
> Subject: [PHP] Dynamic Form
>
>
>> Hell0,
>>
>> I have a MySql database with 3 columns. The first column is "id"
>> second is "name" and third is "value", I have two drop-down lists,
>> with the first filled with an array from the column "name". I would
>> like for the second drop-down list be changed according to the "value"
>
>> of what has been selected in the first drop-down list. I have fill
>> that I'm going in the right direction, but have run into a wall. Can
>> anyone give me some advice in doing this miraculous feat?
>>
>> Thanks,
>>
>> Jared
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED] To
>> contact the list administrators, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED] To
> contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]