Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Jay #1
Kermy.com 3 linked list boxes
I recently purchased a copy of Kermy 3 Dynamic Dependent Drop Down Lists.
The extension looks good. There is just 1 question I have. Is there a way to
get a relation from the child to the grandparent dropdown menu? I have
everything in 1 table and use 3 recordsets for each of the dropdown menus.
The problem is best explained in an example of Cars
Grandparent - Category
Parent - Make
Child - Model
So our Category would be: New Car, Used Car, New SUV, Used SUV...... Makes
would be: Chevy, Ford, Buick ...... Model would be: Explorer, Thunderbird,
Sable.....
The problem is, someone Picks
Grandparent - Used Car
Parent - Ford
Child (here is the problem - the last dropdown list displays all the fords,
not the ones that fit the Category that was selected. So I think there
should be a way to have a relation from the child to the grandparent. Do you
know if this is possible?
Here is the code-I got the ok from Kermy.com to post this.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connUsedAg.asp" -->
<%
Dim rsCategoryMenu
Dim rsCategoryMenu_numRows
Set rsCategoryMenu = Server.CreateObject("ADODB.Recordset")
rsCategoryMenu.ActiveConnection = MM_connUsedAg_STRING
rsCategoryMenu.Source = "SELECT distinct equip_category FROM Equipment"
rsCategoryMenu.CursorType = 0
rsCategoryMenu.CursorLocation = 2
rsCategoryMenu.LockType = 1
rsCategoryMenu.Open()
rsCategoryMenu_numRows = 0
%>
<%
Dim rsMakeMenu
Dim rsMakeMenu_numRows
Set rsMakeMenu = Server.CreateObject("ADODB.Recordset")
rsMakeMenu.ActiveConnection = MM_connUsedAg_STRING
rsMakeMenu.Source = "SELECT distinct equip_make, equip_category FROM
Equipment"
rsMakeMenu.CursorType = 0
rsMakeMenu.CursorLocation = 2
rsMakeMenu.LockType = 1
rsMakeMenu.Open()
rsMakeMenu_numRows = 0
%>
<%
Dim rsModelMenu
Dim rsModelMenu_numRows
Set rsModelMenu = Server.CreateObject("ADODB.Recordset")
rsModelMenu.ActiveConnection = MM_connUsedAg_STRING
rsModelMenu.Source = "SELECT distinct equip_model, equip_make,
equip_category FROM Equipment "
rsModelMenu.CursorType = 0
rsModelMenu.CursorLocation = 2
rsModelMenu.LockType = 1
rsModelMenu.Open()
rsModelMenu_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="JavaScript">
<!--
var GPC_arrDynaList = new Array();
var GPC_arrDL1 = new Array();
GPC_arrDL1[1] = "select_category";
GPC_arrDL1[2] = "form1";
GPC_arrDL1[3] = "select_make";
GPC_arrDL1[4] = "form1";
GPC_arrDL1[5] = GPC_arrDynaList;
<%
Dim GPC_txtDynaListRelation, GPC_txtDynaListLabel, GPC_txtDynaListValue,
GPC_oDynaListRS
GPC_txtDynaListRelation = "equip_category"
GPC_txtDynaListLabel = "equip_make"
GPC_txtDynaListValue = "equip_make"
Set GPC_oDynaListRS = rsMakeMenu
Dim GPC_varDynaList
GPC_varDynaList = -1
Dim GPC_varMaxWidth
GPC_varMaxWidth = "1"
Dim GPC_varCheckGroup
GPC_varCheckGroup =
GPC_oDynaListRS.Fields.Item(GPC_txtDynaListRelatio n).Value
Dim GPC_varCheckLength
GPC_varCheckLength = 0
Dim GPC_varMaxLength
GPC_varMaxLength = 0
While (NOT GPC_oDynaListRS.EOF)
If (GPC_varCheckGroup <>
GPC_oDynaListRS.Fields.Item(GPC_txtDynaListRelatio n).Value) Then
If (GPC_varCheckLength > GPC_varMaxLength) Then
GPC_varMaxLength = GPC_varCheckLength
End If
GPC_varCheckLength = 0
End If
%>
GPC_arrDynaList[<%=(GPC_varDynaList+1)%>] =
"<%=(GPC_oDynaListRS.Fields.Item(GPC_txtDynaListRe lation).Value)%>"
GPC_arrDynaList[<%=(GPC_varDynaList+2)%>] =
"<%=(GPC_oDynaListRS.Fields.Item(GPC_txtDynaListLa bel).Value)%>"
GPC_arrDynaList[<%=(GPC_varDynaList+3)%>] =
"<%=(GPC_oDynaListRS.Fields.Item(GPC_txtDynaListVa lue).Value)%>"
<%
If (len(GPC_oDynaListRS.Fields.Item(GPC_txtDynaListLa bel).Value) >
len(GPC_varMaxWidth)) Then
GPC_varMaxWidth = GPC_oDynaListRS.Fields.Item(GPC_txtDynaListLabel). Value
End If
GPC_varCheckLength = GPC_varCheckLength + 1
GPC_varDynaList = GPC_varDynaList + 3
GPC_oDynaListRS.MoveNext()
Wend
If (GPC_varCheckLength > GPC_varMaxLength) Then
GPC_varMaxLength = GPC_varCheckLength
End If
%>
//-->
</script>
<script language="JavaScript">
<!--
var GPC_arrDynaList2 = new Array();
var GPC_arrDL2 = new Array();
GPC_arrDL2[1] = "select_make";
GPC_arrDL2[2] = "form1";
GPC_arrDL2[3] = "select_model";
GPC_arrDL2[4] = "form1";
GPC_arrDL2[5] = GPC_arrDynaList2;
<%
Dim GPC_txtDynaListRelation2, GPC_txtDynaListLabel2, GPC_txtDynaListValue2,
GPC_oDynaListRS2
GPC_txtDynaListRelation2 = "equip_make"
GPC_txtDynaListLabel2 = "equip_model"
GPC_txtDynaListValue2 = "equip_model"
Set GPC_oDynaListRS2 = rsModelMenu
Dim GPC_varDynaList2
GPC_varDynaList2 = -1
Dim GPC_varMaxWidth2
GPC_varMaxWidth2 = "1"
Dim GPC_varCheckGroup2
GPC_varCheckGroup2 =
GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListRelati on2).Value
Dim GPC_varCheckLength2
GPC_varCheckLength2 = 0
Dim GPC_varMaxLength2
GPC_varMaxLength2 = 0
While (NOT GPC_oDynaListRS2.EOF)
If (GPC_varCheckGroup2 <>
GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListRelati on2).Value) Then
If (GPC_varCheckLength2 > GPC_varMaxLength2) Then
GPC_varMaxLength2 = GPC_varCheckLength2
End If
GPC_varCheckLength2 = 0
End If
%>
GPC_arrDynaList2[<%=(GPC_varDynaList2+1)%>] =
"<%=(GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListR elation2).Value)%>"
GPC_arrDynaList2[<%=(GPC_varDynaList2+2)%>] =
"<%=(GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListL abel2).Value)%>"
GPC_arrDynaList2[<%=(GPC_varDynaList2+3)%>] =
"<%=(GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListV alue2).Value)%>"
<%
If (len(GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListL abel2).Value) >
len(GPC_varMaxWidth2)) Then
GPC_varMaxWidth2 =
GPC_oDynaListRS2.Fields.Item(GPC_txtDynaListLabel2 ).Value
End If
GPC_varCheckLength2 = GPC_varCheckLength2 + 1
GPC_varDynaList2 = GPC_varDynaList2 + 3
GPC_oDynaListRS2.MoveNext()
Wend
If (GPC_varCheckLength2 > GPC_varMaxLength2) Then
GPC_varMaxLength2 = GPC_varCheckLength2
End If
%>
//-->
</script>
<script language="JavaScript">
<!--
function setDynaList(GPC_arrDL){
var oList1 = document.forms[GPC_arrDL[2]].elements[GPC_arrDL[1]];
var oList2 = document.forms[GPC_arrDL[4]].elements[GPC_arrDL[3]];
var arrList = GPC_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[i] = null;
}
oList.selectedIndex = -1;
}
function populateDynaList(oList, nIndex, aArray){
for (var i = 0; i < aArray.length; i= i + 3){
if (aArray[i] == 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 GPC_Kermy_JS(jsStr) {
return eval(jsStr)
}
//-->
</script>
Jay Guest
-
linked text boxes on master pages?
Hey Guys Im having a small problem figuring out how to do something. I have a master page with facing pages and I put text boxes on both and then... -
MXa bug in linked text boxes
have anybody noticed this: type few lines of text draw new empty text box link text boxes together select few words take a look to... -
Wizards (Combo and List boxes)
I'm having problems with the Combo box and List box wizards in Access 2000 (on Win XP) I have the Wizard button on the toolbox depressed. When I... -
Linked Combo Boxes and Automatic Field entries
Hello VB - I hope you didn't think I was being rude in not thanking you for your help, but I have only just solved the problem! I followed your... -
Managing linked list through child processes
In article <bO_La.287$W51.134@reader1.news.jippii.net>, Geeco <katjaso76@hotmail.com> wrote: Learn about "shared memory". -- Barry Margolin,...



Reply With Quote

