Hi, am trying to create a 6 step search menu, where first drop-down menu selection affects the second drop-down menu selection affects the third and so on (All of the menus items/arrays if nec. need to be database driven)...
My menu items are as follows: Product Line/ Capacity / Thread / Style / Material / Color
In addition I need to show the results of the search (which will also be pulled from the same database) in a list box on the right.
For example: If the user selects Plastic Jars from the Product Line menu, the Capacity Menu will then update to show all of the capacities that are available for plastic jars. In addition, the list box on the right will show a brief description of all of the Plastic Jars offered (one line per jar). The user will then have the option to narrow the search futher using the menu on the left or choose the items they are looking for from directly from the list box on the right. The list box items need to be somehow linked so that after a user makes there selection and presses the view products button it takes them to a summary page where the information that they have chosen is expanded upon with a pix etc. Like a product cataolg...
The way that my database is currently set up, the description that needs to appear in the results box is a combination of several fields in the same table.
I found this article on the macromedia website about setting up dynamic dependant menus but I can't seem to get it to work.
http://www.macromedia.com/support/ultradev/ts/documents/client_dynamic_listbox.htm
What am I missing? I think it may have something to do with the queries that I have set up or maybe my relationships are wrong? I have no idea. Can you help me, maybe highlight what needs changing and how to change it. thanks.
<?php require_once('Connections/krdesign4ucom.php'); ?>
<?php
mysql_select_db($database_krdesign4ucom, $krdesign4ucom);
$query_ProdLine = "SELECT * FROM Jars GROUP BY 'PRODLINE'";
$ProdLine = mysql_query($query_ProdLine, $krdesign4ucom) or die(mysql_error());
$row_ProdLine = mysql_fetch_assoc($ProdLine);
$totalRows_ProdLine = mysql_num_rows($ProdLine);
mysql_select_db($database_krdesign4ucom, $krdesign4ucom);
$query_Capacity = "SELECT * FROM Jars GROUP BY capacity ORDER BY CAPACITY ASC";
$Capacity = mysql_query($query_Capacity, $krdesign4ucom) or die(mysql_error());
$row_Capacity = mysql_fetch_assoc($Capacity);
$totalRows_Capacity = mysql_num_rows($Capacity);
mysql_select_db($database_krdesign4ucom, $krdesign4ucom);
$query_Thread = "SELECT * FROM Jars GROUP BY THREAD ORDER BY THREAD ASC";
$Thread = mysql_query($query_Thread, $krdesign4ucom) or die(mysql_error());
$row_Thread = mysql_fetch_assoc($Thread);
$totalRows_Thread = mysql_num_rows($Thread);
mysql_select_db($database_krdesign4ucom, $krdesign4ucom);
$query_Style = "SELECT * FROM Jars GROUP BY STYLE ORDER BY STYLE ASC";
$Style = mysql_query($query_Style, $krdesign4ucom) or die(mysql_error());
$row_Style = mysql_fetch_assoc($Style);
$totalRows_Style = mysql_num_rows($Style);
mysql_select_db($database_krdesign4ucom, $krdesign4ucom);
$query_Material = "SELECT * FROM Jars GROUP BY material ORDER BY material ASC";
$Material = mysql_query($query_Material, $krdesign4ucom) or die(mysql_error());
$row_Material = mysql_fetch_assoc($Material);
$totalRows_Material = mysql_num_rows($Material);
mysql_select_db($database_krdesign4ucom, $krdesign4ucom);
$query_Color = "SELECT * FROM Jars GROUP BY color ORDER BY color ASC";
$Color = mysql_query($query_Color, $krdesign4ucom) or die(mysql_error());
$row_Color = mysql_fetch_assoc($Color);
$totalRows_Color = mysql_num_rows($Color);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Dynamic Dependent List box Code for JavaScript Server Model //-->
<script language="JavaScript">
<!--
var arrDynaList = new Array();
var arrDL1 = new Array();
arrDL1[1] = "prodline"; // Name of parent list box
arrDL1[2] = "form1"; // Name of form containing parent list box
arrDL1[3] = "capacity"; // Name of child list box
arrDL1[4] = "form1"; // Name of form containing child list box
arrDL1[5] = arrDynaList;
<%
var txtDynaListRelation, txtDynaListLabel, txtDynaListValue, oDynaListRS;
txtDynaListRelation = "prodline" // Name of recordset field relating to parent
txtDynaListLabel = "capacity" // Name of recordset field for child Item Label
txtDynaListValue = "capacity" // Name of recordset field for child Value
oDynaListRS = capacity // Name of child list box recordset
var varDynaList = -1;
var varMaxWidth = "1";
var varCheckGroup = oDynaListRS.Fields.Item(txtDynaListRelation).Value;
var varCheckLength = 0;
var varMaxLength = 0;
while (!oDynaListRS.EOF){
if (varCheckGroup != oDynaListRS.Fields.Item(txtDynaListRelation).Value) {
varMaxLength = Math.max(varCheckLength, varMaxLength)
varCheckLength = 0;
}
%>
arrDynaList[<%=(varDynaList+1)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListRelation).Value)%>";
arrDynaList[<%=(varDynaList+2)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListLabel).Value)%>";
arrDynaList[<%=(varDynaList+3)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListValue).Value)%>";
<%
if (oDynaListRS.Fields.Item(txtDynaListLabel).Value.length > varMaxWidth.length) {
varMaxWidth = oDynaListRS.Fields.Item(txtDynaListLabel).Value;
}
varCheckLength = varCheckLength + 1;
varDynaList = varDynaList + 3;
oDynaListRS.MoveNext();
}
varMaxLength = Math.max(varCheckLength, varMaxLength)
%>
//-->
</script>
<!-- End of object/array definitions, beginning of generic functions -->
<script language="JavaScript">
<!--
function setDynaList(arrDL){
var oList1 = document.forms[arrDL[2]].elements[arrDL[1]]
var oList2 = document.forms[arrDL[4]].elements[arrDL[3]]
var arrList = arrDL[5]
clearDynaList(oList2);
if (oList1.selectedIndex == -1){
oList1.selectedIndex = 0;
}
populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
return true;
}
function clearDynaList(oList){
for (var i = oList.options.length; i >= 0; i--){
oList.options = null;
}
oList.selectedIndex = -1;
}
function populateDynaList(oList, nIndex, aArray){
for (var i = 0; i < aArray.length; i= i + 3){
if (aArray == nIndex){
oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
}
}
if (oList.options.length == 0){
oList.options[oList.options.length] = new Option("[none available]",0);
}
oList.selectedIndex = 0;
}
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
</head>
<body onLoad="MM_callJS('setDynaList(arrDL1)')">
<p><br>
</p>
<form name="form1" method="post" action="">
<p>Step 1: Select Product Line<br>
<select name="prodline" id="prodline" onChange="MM_callJS('setDynaList(arrDL1)')">
<?php
do {
?>
<option value="<?php echo $row_ProdLine['PRODLINE']?>"<?php if (!(strcmp($row_ProdLine['PRODLINE'], $row_ProdLine['PRODLINE']))) {echo "SELECTED";} ?>><?php echo $row_ProdLine['PRODLINE']?></option>
<?php
} while ($row_ProdLine = mysql_fetch_assoc($ProdLine));
$rows = mysql_num_rows($ProdLine);
if($rows > 0) {
mysql_data_seek($ProdLine, 0);
$row_ProdLine = mysql_fetch_assoc($ProdLine);
}
?>
</select>
</p>
<p>Step 2: Select a Capacity<br>
<select name="capacity">
<%
for (varLoopCounter = 1; varLoopCounter <= varMaxLength; varLoopCounter++){
%>
<option value = "<%=varMaxWidth%>"><%=varMaxWidth%></option>
<%
}
%>
</select>
</p>
<p>Step 3: Select a Thread Size<br>
<select name="thread" id="thread">
</select>
</p>
<p>Step 4: Choose a Style<br>
<select name="style" id="style">
</select>
</p>
<p>Step 5: Choose a Material<br>
<select name="material" id="material">
</select>
</p>
<p>Step 6: Select a Color<br>
<select name="color" id="color">
</select>
</p>
<p> </p>
</form>
</body>
</html>
<?php
mysql_free_result($ProdLine);
mysql_free_result($Capacity);
mysql_free_result($Thread);
?>