secondreckoned
Technical User
Hi,
I'm trying to create a three tier drop down list, the first dropdownlist will display type of job to be done ("WORKGROUPID"), once this is selected a list of Dispatch regions will appear ("DISPATCHREGIONID") which in turn will sort the third drop down list to show dispatch area's within each region ("DISPATCHAREAID"). I am able to get it to sort after I hit the form submit button, but not in the "onchange" event when I select workgroup or region. Here is the code, would appreciate any help as to why?
Thx.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<%
Set objADOConn = Server.CreateObject("ADODB.Connection")
sConnect = "Driver={SQL Server};" & _
"Server=XXXXXX;" & _
"Database=XXXXXXX;" & _
"Uid=XXXXX;" & _
"Pwd=XXXXXX;"
objADOConn.ConnectionString = sConnect
objADOConn.Open
strWORKGROUPID = request.form("WorkGroup")
strDISPATCHREGIONID = Request.Form("DispatchRegion")
response.Write(strWORKGROUPID)
Sub fillWorkGroup()
Set WorkGroupRS = Server.CreateObject("ADODB.RecordSet")
WG = ("SELECT DISTINCT WORKGROUPID FROM tb_DispatchArea ORDER BY WORKGROUPID")
WorkGroupRS.Open WG, sConnect
do while not WorkgroupRS.EOF
if WorkGroupRS("WORKGROUPID") = strWORKGROUPID then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" & WorkGroupRS("WORKGROUPID") & "</option>" & VBCRLF )
WorkGroupRS.MoveNext
loop
WorkGroupRS.Close
set WorkGroupRS=Nothing
End Sub
Sub fillDispatchRegion
Set DispatchRegionRS = Server.CreateObject("ADODB.RecordSet")
DR = ("SELECT DISTINCT DISPATCHREGIONID FROM tb_DispatchArea Where WORKGROUPID = '" & strWORKGROUPID & "' ORDER BY DISPATCHREGIONID")
DispatchRegionRS.Open DR, sConnect
If DispatchRegionRS.EOF Then
Response.Write("<option>No Regions Found</option>")
else
Response.Write("<option>Select Region Now</option>" & VBCRLF)
Do While Not DispatchRegionRS.EOF
If DispatchRegionRS("DISPATCHREGIONID") = strDISPATCHREGION Then
strSelected = "Selected"
Else
strSelected = ""
End If
Response.Write("<option" & strSelected & ">" & DispatchRegionRS("DISPATCHREGIONID") & "</option>" & VBCRLF )
DispatchRegionRS.MoveNext
loop
End If
DispatchRegionRS.Close
set DispatchRegionRS=Nothing
End Sub
Sub fillDispatchArea
Set DispatchAreaRS = Server.CreateObject("ADODB.RecordSet")
DA = ("SELECT DISTINCT DISPATCHAREAID FROM tb_DispatchArea WHERE DISPATCHREGIONID ='" &strDispatchRegion & "' ORDER BY DISPATCHAREAID")
DispatchAreaRS.Open DA, sConnect
do while not DispatchAreaRS.EOF
if DispatchAreaRS("DISPATCHAREAID") = DISPATCHAREAID then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" & DispatchAreaRS("DISPATCHAREAID") & "</option>" & VBCRLF )
DispatchAreaRS.MoveNext
loop
DispatchAreaRS.Close
set DispatchAreaRS=Nothing
End Sub
%>
<head>
<title>Untitled Document</title>
</head>
<body>
<SCRIPT LANGUAGE=javascript>
<!--
function submitWG(){
var objForm = document.forms[0];
objForm.elements['DispatchRegion'].selectedIndex=0;
objForm.elements['DispatchArea'].selectedIndex = 0;
objForm.submit();
}
function submitDR(){
var objForm = document.forms[0];
objForm.elements['DispatchArea'].selectedIndex = 0;
objForm.submit();
}
function submitForm(){
var objForm = document.forms[0];
objForm.action = "drop1.asp"
return true;
}
//-->
</SCRIPT>
<table>
<form action="" method="post" id="form1" onSubmit="return submitForm()">
<tr>
<td align="center">
WorkGroup
</td>
<td align="center">
Dispatch Region
</td>
<td align="center">
Dispatch Area
</td>
</tr>
<tr>
<td align="center">
<select name="WorkGroup" onChange="submitWG()">
<% Call fillWorkGroup %>
</select>
</td>
<td align="center">
<select name="DispatchRegion" onChange="submitDR()">
<% Call fillDispatchRegion %>
</select>
</td>
<td align="center">
<select name="DispatchArea">
<% Call fillDispatchArea %>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit">
</td>
</tr>
</form>
</body>
</html>
I'm trying to create a three tier drop down list, the first dropdownlist will display type of job to be done ("WORKGROUPID"), once this is selected a list of Dispatch regions will appear ("DISPATCHREGIONID") which in turn will sort the third drop down list to show dispatch area's within each region ("DISPATCHAREAID"). I am able to get it to sort after I hit the form submit button, but not in the "onchange" event when I select workgroup or region. Here is the code, would appreciate any help as to why?
Thx.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<%
Set objADOConn = Server.CreateObject("ADODB.Connection")
sConnect = "Driver={SQL Server};" & _
"Server=XXXXXX;" & _
"Database=XXXXXXX;" & _
"Uid=XXXXX;" & _
"Pwd=XXXXXX;"
objADOConn.ConnectionString = sConnect
objADOConn.Open
strWORKGROUPID = request.form("WorkGroup")
strDISPATCHREGIONID = Request.Form("DispatchRegion")
response.Write(strWORKGROUPID)
Sub fillWorkGroup()
Set WorkGroupRS = Server.CreateObject("ADODB.RecordSet")
WG = ("SELECT DISTINCT WORKGROUPID FROM tb_DispatchArea ORDER BY WORKGROUPID")
WorkGroupRS.Open WG, sConnect
do while not WorkgroupRS.EOF
if WorkGroupRS("WORKGROUPID") = strWORKGROUPID then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" & WorkGroupRS("WORKGROUPID") & "</option>" & VBCRLF )
WorkGroupRS.MoveNext
loop
WorkGroupRS.Close
set WorkGroupRS=Nothing
End Sub
Sub fillDispatchRegion
Set DispatchRegionRS = Server.CreateObject("ADODB.RecordSet")
DR = ("SELECT DISTINCT DISPATCHREGIONID FROM tb_DispatchArea Where WORKGROUPID = '" & strWORKGROUPID & "' ORDER BY DISPATCHREGIONID")
DispatchRegionRS.Open DR, sConnect
If DispatchRegionRS.EOF Then
Response.Write("<option>No Regions Found</option>")
else
Response.Write("<option>Select Region Now</option>" & VBCRLF)
Do While Not DispatchRegionRS.EOF
If DispatchRegionRS("DISPATCHREGIONID") = strDISPATCHREGION Then
strSelected = "Selected"
Else
strSelected = ""
End If
Response.Write("<option" & strSelected & ">" & DispatchRegionRS("DISPATCHREGIONID") & "</option>" & VBCRLF )
DispatchRegionRS.MoveNext
loop
End If
DispatchRegionRS.Close
set DispatchRegionRS=Nothing
End Sub
Sub fillDispatchArea
Set DispatchAreaRS = Server.CreateObject("ADODB.RecordSet")
DA = ("SELECT DISTINCT DISPATCHAREAID FROM tb_DispatchArea WHERE DISPATCHREGIONID ='" &strDispatchRegion & "' ORDER BY DISPATCHAREAID")
DispatchAreaRS.Open DA, sConnect
do while not DispatchAreaRS.EOF
if DispatchAreaRS("DISPATCHAREAID") = DISPATCHAREAID then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" & DispatchAreaRS("DISPATCHAREAID") & "</option>" & VBCRLF )
DispatchAreaRS.MoveNext
loop
DispatchAreaRS.Close
set DispatchAreaRS=Nothing
End Sub
%>
<head>
<title>Untitled Document</title>
</head>
<body>
<SCRIPT LANGUAGE=javascript>
<!--
function submitWG(){
var objForm = document.forms[0];
objForm.elements['DispatchRegion'].selectedIndex=0;
objForm.elements['DispatchArea'].selectedIndex = 0;
objForm.submit();
}
function submitDR(){
var objForm = document.forms[0];
objForm.elements['DispatchArea'].selectedIndex = 0;
objForm.submit();
}
function submitForm(){
var objForm = document.forms[0];
objForm.action = "drop1.asp"
return true;
}
//-->
</SCRIPT>
<table>
<form action="" method="post" id="form1" onSubmit="return submitForm()">
<tr>
<td align="center">
WorkGroup
</td>
<td align="center">
Dispatch Region
</td>
<td align="center">
Dispatch Area
</td>
</tr>
<tr>
<td align="center">
<select name="WorkGroup" onChange="submitWG()">
<% Call fillWorkGroup %>
</select>
</td>
<td align="center">
<select name="DispatchRegion" onChange="submitDR()">
<% Call fillDispatchRegion %>
</select>
</td>
<td align="center">
<select name="DispatchArea">
<% Call fillDispatchArea %>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit">
</td>
</tr>
</form>
</body>
</html>