Drop down | dropdown | dropdown | drop-down list has [group] and [user] Two data tables, requires that the data be read from both tables and displayed as a level two Drop-down table, and the options in the [user] list change accordingly when you select an option in the [Group] list.
The [Group] table corresponds to a dataset of Rsgroup, with the following fields: Lngid_group, Strname_group
The [user] table corresponds to a dataset of Rsuser, with the following fields: Lngid_user, Lnggroupid, Strname_user
Idea: Create a drop-down list of group and user, read the data for Rsgroup and Rsuser, and then create the Change_select () function to update the user Drop-down list when the group's Drop-down list is changed.
The code is as follows:
<!-group Drop-down List-------------->
<select name= "Sltgroupid"
>
<option value= "0" > User group ......</option>
<%
For i = 1 to Rsgroup.recordcount
Response.Write "<option value= '" & Lngid_group & "' >" & strname_group & "</option>"
Rsgroup.movenext
Next
%>
</select>
<!-user Drop-down List-------------->
<select name= "Sltuserid" >
<option value= "0" > User ......</option>
</select>
<script language = "JavaScript" >
Read the Rsuser data
Arrselect=new Array ();
Arrselect[0] = new Array ("User ...", 0,0)
<%
For i = 1 to Rsuser.recordcount
%>
arrselect[<%= I%>]=new Array ("<%= strname_user%>", "<%= lnggroupid%>", "<%= lngID_User%>");
<%
Rsuser.movenext
Next
%>
function to update the user Drop-down list
function Change_select (selvalue)
{
document.all.sltuserid.length=0;
var i;
for (i=0;i<arrselect.length;i++)
{
if (Arrselect[i][1]==selvalue)
{
var newoption=new Option (arrselect[i][0],arrselect[i][2]);
Document.all.sltUserID.add (newoption);
}
}
}
</script>
The results of the operation are as follows:
<!-group Drop-down List-------------->
<select name= "Sltgroupid"
>
<option selected value= "0" > User group ......</option>
<option value= ' 1 ' > Immediate institutions </option>
<option value= ' 2 ' > Office </option>
<option value= ' 3 ' > Technical Department </option>
</select>
<!-user Drop-down List-------------->
<select name= "Sltuserid" >
<option selected value= "0" > User ......</option>
</select>
<script language = "JavaScript" >
Read the Rsuser data
Arrselect=new Array ();
Arrselect[0]=new Array ("User ...", 0,0)
Arrselect[1]=new Array ("General manager", "1", "1");
Arrselect[2]=new Array ("Network Center", "1", "15");
Arrselect[3]=new Array ("Public Platform", "1", "4");
Arrselect[4]=new Array ("aftermarket department", "1", "20");
Arrselect[5]=new Array ("Guangzhou", "2", "24");
Arrselect[6]=new Array ("Shanghai", "2", "23");
Arrselect[7]=new Array ("Pre-sales Support", "3", "8");
Arrselect[8]=new Array ("Research and Development Center", "3", "9");
function to update the user Drop-down list
function Change_select (selvalue)
{
Ditto, slightly.
}
</script>