simflex
09-17-2003, 01:04 PM
Can you please, please help.
I have a dynamic dropdown list box where the second dropdown is populated with data from the first dropdown.
This works fine.
This is a two-page form. After completing first page, you click continue to go to the second page.
Problem I discovered is that when the client clicks the back button to go back to first page,or an error is encountered and the client needs to go back to first page to correct it, the value in the dropdown is cleared requiring the client to select the first dropdown again to repopulate the second.
The rest of the values in every input text box is not cleared. Only the dropdown box is getting cleared.
There is got to be a way to fix this problem.
Please help.
Second, I am required to expand the dependent list box to 3.
Which means that the second and third dropdown boxes are populated with data from the first dropdown.
For instance, the first dropdown will now be employee.
Once you select a name for the first dropdown box, the second and third are populated based on the value from the first dropdown.
If anyone can help with one or both of these, I will GREATLY appreciate it.
Here is the current dependent dropdown list where second dropdown is populated with data from the first dropdown.
This is also the one where values disappear once you click the back button.
<%
Response.Buffer = True
set safetyDB = Server.CreateObject("ADODB.Connection")
safetyDB.Open "dsn=safety"
sql = "SELECT * FROM theEmp "
set rs = safetyDB.execute(sql)
%>
<head>
<script language = "JavaScript">
function subcat()
{
cat = document.subad.org[document.subad.org.selectedIndex].value;
url = "CorrectEmployeeData.asp?cat=";
url = url + cat;
window.location.href = url;
}
function sublist(inform, selecteditem)
{
inform.division.length = 0
<%
count= 0
y=0
do while not rs.eof
%>
x = <%= trim(y) %>
subcat = new Array();
division = "<%= trim(rs("division"))%>"
org = "<%= trim(rs("org"))%>"
empid = "<%= trim(rs("empid"))%>"
subcat[x,0] = division;
subcat[x,1] = org;
subcat[x,2] = empid;
if (subcat[x,1] == selecteditem)
{
var option<%= trim(count) %> = new Option(subcat[x,0], subcat[x,2])
inform.division.options[inform.division.length]=option<%=trim(count)%>
}
<%
count = count + 1
y = y + 1
rs.movenext
loop
%>
}
</script>
</head>
<body>
<TABLE border="2" bgcolor="ffffff" width="100%">
<TR>
<TD ALIGN=left width="65%"><font size="-1" style="arial8">Employee's Org</font></TD>
<TD ALIGN=LEFT>
<%
cat = Request.QueryString("cat")
sql = "SELECT * from org order by orgcode desc"
set rs = safetyDB.execute (sql)
%>
<SELECT id=org name=org onChange = "sublist(this.form, document.subad.org[document.subad.org.selectedIndex].value)">
<%
do until rs.eof
isSelected=""
if rs("orgid")=rs("orgid") then
isSelected=" Selected "
end if
%>
<OPTION value="<%= rs("orgID")%>" <%=isSelected%>><% = rs("orgCode")%></OPTION>
<%
rs.movenext
loop
set rs = nothing
%>
</SELECT>
<%if errorcode1 = "yes" then%> <font color="#FF0000"><strong>*please insert the employee's org
</strong> </font> <%end if%>
</TD>
<TD ALIGN=left width="65%"><font size="-1" style="arial8">Division</font></TD>
<TD ALIGN=LEFT>
<select id = "division" name="division">
<option value="invalid">-----------</option>
</select>
</TD>
</TR>
</TABLE>
</body>
I have a dynamic dropdown list box where the second dropdown is populated with data from the first dropdown.
This works fine.
This is a two-page form. After completing first page, you click continue to go to the second page.
Problem I discovered is that when the client clicks the back button to go back to first page,or an error is encountered and the client needs to go back to first page to correct it, the value in the dropdown is cleared requiring the client to select the first dropdown again to repopulate the second.
The rest of the values in every input text box is not cleared. Only the dropdown box is getting cleared.
There is got to be a way to fix this problem.
Please help.
Second, I am required to expand the dependent list box to 3.
Which means that the second and third dropdown boxes are populated with data from the first dropdown.
For instance, the first dropdown will now be employee.
Once you select a name for the first dropdown box, the second and third are populated based on the value from the first dropdown.
If anyone can help with one or both of these, I will GREATLY appreciate it.
Here is the current dependent dropdown list where second dropdown is populated with data from the first dropdown.
This is also the one where values disappear once you click the back button.
<%
Response.Buffer = True
set safetyDB = Server.CreateObject("ADODB.Connection")
safetyDB.Open "dsn=safety"
sql = "SELECT * FROM theEmp "
set rs = safetyDB.execute(sql)
%>
<head>
<script language = "JavaScript">
function subcat()
{
cat = document.subad.org[document.subad.org.selectedIndex].value;
url = "CorrectEmployeeData.asp?cat=";
url = url + cat;
window.location.href = url;
}
function sublist(inform, selecteditem)
{
inform.division.length = 0
<%
count= 0
y=0
do while not rs.eof
%>
x = <%= trim(y) %>
subcat = new Array();
division = "<%= trim(rs("division"))%>"
org = "<%= trim(rs("org"))%>"
empid = "<%= trim(rs("empid"))%>"
subcat[x,0] = division;
subcat[x,1] = org;
subcat[x,2] = empid;
if (subcat[x,1] == selecteditem)
{
var option<%= trim(count) %> = new Option(subcat[x,0], subcat[x,2])
inform.division.options[inform.division.length]=option<%=trim(count)%>
}
<%
count = count + 1
y = y + 1
rs.movenext
loop
%>
}
</script>
</head>
<body>
<TABLE border="2" bgcolor="ffffff" width="100%">
<TR>
<TD ALIGN=left width="65%"><font size="-1" style="arial8">Employee's Org</font></TD>
<TD ALIGN=LEFT>
<%
cat = Request.QueryString("cat")
sql = "SELECT * from org order by orgcode desc"
set rs = safetyDB.execute (sql)
%>
<SELECT id=org name=org onChange = "sublist(this.form, document.subad.org[document.subad.org.selectedIndex].value)">
<%
do until rs.eof
isSelected=""
if rs("orgid")=rs("orgid") then
isSelected=" Selected "
end if
%>
<OPTION value="<%= rs("orgID")%>" <%=isSelected%>><% = rs("orgCode")%></OPTION>
<%
rs.movenext
loop
set rs = nothing
%>
</SELECT>
<%if errorcode1 = "yes" then%> <font color="#FF0000"><strong>*please insert the employee's org
</strong> </font> <%end if%>
</TD>
<TD ALIGN=left width="65%"><font size="-1" style="arial8">Division</font></TD>
<TD ALIGN=LEFT>
<select id = "division" name="division">
<option value="invalid">-----------</option>
</select>
</TD>
</TR>
</TABLE>
</body>