Asp.net two-level linkage (including adding and modifying)
Last Update:2018-12-08
Source: Internet
Author: User
<Script language = "JavaScript" type = "text/JavaScript">
// Initialize the subject data
VaR subcat = new array ();
Subcat [0] = new array ('0', 'select subject ', '0 ');
Subcat [1] = new array ('x1', 'China', 'x1yw ');
Subcat [2] = new array ('x2 ', 'China', 'x2w ');
Subcat [3] = new array ('x3', 'China', 'x3yw ');
Subcat [4] = new array ('x4 ', 'China', 'x4yw ');
Subcat [5] = new array ('x5 ', 'China', 'x5yw ');
Subcat [6] = new array ('x6 ', 'China', 'x6yw ');
Subcat [7] = new array ('c5 ', 'China', 'c5w ');
Subcat [8] = new array ('c6 ', 'China', 'c6yw ');
Subcat [9] = new array ('c7w', 'China ');
Subcat [10] = new array ('g1', 'China', 'g1yw ');
Subcat [11] = new array ('g3 ', 'China', 'g3w ');
Subcat [12] = new array ('g4 ', 'China', 'g4w ');
Subcat [13] = new array ('x1 ', 'mat', 'x1sx ');
Subcat [14] = new array ('x2 ', 'mat', 'x2sx ');
Subcat [15] = new array ('x3', 'mat', 'x3sx ');
Subcat [16] = new array ('x4 ', 'mat', 'x4sx ');
Subcat [17] = new array ('x5 ', 'mat', 'x5sx ');
Subcat [18] = new array ('x6 ', 'mat', 'x6sx ');
Subcat [19] = new array ('c5 ', 'mat', 'c5sx ');
Subcat [20] = new array ('c6 ', 'mat', 'c6sx ');
Subcat [21] = new array ('c7 ', 'mat', 'c7sx ');
Subcat [22] = new array ('g1', 'mat', 'g1sx ');
Subcat [23] = new array ('g3 ', 'mat', 'g3sx ');
Subcat [24] = new array ('g4 ', 'mat', 'g4sx ');
Subcat [25] = new array ('x1', 'English ', 'x1yy ');
Subcat [26] = new array ('x2 ', 'English', 'x2yy ');
Subcat [27] = new array ('x3', 'English ', 'x3yy ');
Subcat [28] = new array ('x4 ', 'English', 'x4yy ');
Subcat [29] = new array ('x5 ', 'English', 'x5yy ');
Subcat [30] = new array ('x6 ', 'English', 'x6yy ');
Subcat [31] = new array ('c5 ', 'English', 'c5yy ');
Subcat [32] = new array ('c6 ', 'English', 'c6yy ');
Subcat [33] = new array ('c7yy', 'English ', 'c7yy ');
Subcat [34] = new array ('g1', 'English ', 'g1yy ');
Subcat [35] = new array ('g3 ', 'English', 'g3yy ');
Subcat [36] = new array ('g4 ', 'English', 'g4yy ');
Subcat [37] = new array ('c5 ', 'Physical', 'c5wl ');
Subcat [38] = new array ('c6 ', 'Physical', 'c6wl ');
Subcat [39] = new array ('c7wl ', 'Physical', 'c7wl ');
Subcat [40] = new array ('g1', 'Physical ', 'g1wl ');
Subcat [41] = new array ('g3 ', 'Physical', 'g3wl ');
Subcat [42] = new array ('g4 ', 'Physical', 'g4wl ');
Subcat [43] = new array ('c5 ', 'chemistry', 'c5hx ');
Subcat [44] = new array ('c6 ', 'chemistry', 'c6hx ');
Subcat [45] = new array ('c7hx ', 'chemistry', 'c7hx ');
Subcat [46] = new array ('g1', 'chemistry ', 'g1hx ');
Subcat [47] = new array ('g3 ', 'chemistry', 'g3hx ');
Subcat [48] = new array ('g4 ', 'chemistry', 'g4hx ');
Subcat [49] = new array ('c5 ', 'political', 'c5zz ');
Subcat [50] = new array ('c6 ', 'political', 'c6zz ');
Subcat [51] = new array ('c7zz ', 'political', 'c7zz ');
Subcat [52] = new array ('g1', 'political ', 'g1zz ');
Subcat [53] = new array ('g3 ', 'political', 'g3zz ');
Subcat [54] = new array ('g4 ', 'political', 'g4zz ');
Subcat [55] = new array ('c5 ', 'hire', 'c5ls ');
Subcat [56] = new array ('c6 ', 'hire', 'c6ls ');
Subcat [57] = new array ('c7ls', 'hire', 'c7ls ');
Subcat [58] = new array ('g1', 'hire', 'g1ls ');
Subcat [59] = new array ('g3 ', 'hire', 'g3ls ');
Subcat [60] = new array ('g4 ', 'hire', 'g4ls ');
Subcat [61] = new array ('c5 ', 'bio', 'c5sw ');
Subcat [62] = new array ('c6 ', 'bio', 'c6sw ');
Subcat [63] = new array ('c7 ', 'bio', 'c7sw ');
Subcat [64] = new array ('g1', 'bio', 'g1sw ');
Subcat [65] = new array ('g3 ', 'bio', 'g3sw ');
Subcat [66] = new array ('g4 ', 'bio', 'g4sw ');
Subcat [67] = new array ('c5 ', 'geolocation', 'c5dl ');
Subcat [68] = new array ('c6 ', 'geolocation', 'c6dl ');
Subcat [69] = new array ('c7dl ', 'geolocation', 'c7dl ');
Subcat [70] = new array ('g1', 'geolocation ', 'g1dl ');
Subcat [71] = new array ('g3 ', 'geolocation', 'g3dl ');
Subcat [72] = new array ('g4 ', 'geolocation', 'g4dl ');
Subcat [73] = new array ('x1', 'others', 'x1qt ');
Subcat [74] = new array ('x2 ', 'others', 'x2qt ');
Subcat [75] = new array ('x3', 'off', 'x3qt ');
Subcat [76] = new array ('x4 ', 'others', 'x4qt ');
Subcat [77] = new array ('x5 ', 'others', 'x5qt ');
Subcat [78] = new array ('x6 ', 'others', 'x6qt ');
Subcat [79] = new array ('c5 ', 'others', 'c5qt ');
Subcat [80] = new array ('c6 ', 'others', 'c6qt ');
Subcat [81] = new array ('c7 ', 'others', 'c7qt ');
Subcat [82] = new array ('g1 ', 'others', 'g1qt ');
Subcat [83] = new array ('g3 ', 'others', 'g3qt ');
Subcat [84] = new array ('g4 ', 'others', 'g4qt ');
// Select the Grade
Function changegrade (OBJ, ID)
{
VaR oobj = Document. getelementbyid (ID );
Oobj. Length = 0;
For (I = 0; I <subcat. length; I ++)
{
If (subcat [I] [0] = OBJ)
{
Oobj. Options [oobj. Length] = New Option (subcat [I] [1], subcat [I] [2]);
}
}
}
// Modify the account data loading page
Function loadingcourse ()
{
VaR subjectselect = "<% = subjectselect %> ";
VaR gradeselect = "<% = gradeselect %> ";
If (subjectselect! = "")
{
Loadingsubject (gradeselect, 'Course', subjectselect );
}
}
Function loadingsubject (OBJ, ID, Sid)
{
VaR SLT = Document. Forms [0]. elements ["ID"];
VaR oobj = Document. getelementbyid (ID );
Oobj. Length = 0;
Oobj. Options [0] = New Option ('all accounts', '0 ');
For (I = 0; I <subcat. length; I ++)
{
If (subcat [I] [0] = OBJ)
{
Oobj. Options [oobj. Length] = New Option (subcat [I] [1], subcat [I] [2]);
If (subcat [I] [2] = Sid)
{
Oobj. Options [oobj. Length-1]. Selected = true;
}
}
}
}
</SCRIPT>
<Body onload = "loadingcourse ();">
<Select name = "Grade" id = "Grade" class = "input" onchange = "changegrade (this. Value, 'Course')">
<Option value = "0"> select Grade </option>
<Option value = "X1" <% = gradeselect = "X1 "? "Selected": "" %> First Grade </option>
<Option value = "X2" <% = gradeselect = "X2 "? "Selected": "" %> grade 2 </option>
<Option value = "X3" <% = gradeselect = "X3 "? "Selected": "" %> grade 3 </option>
<Option value = "X4" <% = gradeselect = "X4 "? "Selected": "" %> grade 4 </option>
<Option value = "X5" <% = gradeselect = "X5 "? "Selected": "" %> Fifth Grade </option>
<Option value = "X6" <% = gradeselect = "X6 "? "Selected": "" %> Sixth Grade </option>
<Option value = "C5" <% = gradeselect = "C5 "? "Selected": "" %> Seventh Grade </option>
<Option value = "C6" <% = gradeselect = "C6 "? "Selected": "" %> Eighth Grade </option>
<Option value = "C7" <% = gradeselect = "C7 "? "Selected": "" %> grade 9 </option>
<Option value = "g1" <% = gradeselect = "g1 "? "Selected": "" %> Senior One </option>
<Option value = "G3" <% = gradeselect = "G3 "? "Selected": "" %> sophomore year </option>
<Option value = "G4" <% = gradeselect = "G4 "? "Selected": "" %> Senior Three </option>
</SELECT>
<Select name = "Course" id = "Course" class = "input">
<Option value = "0"> select Grade </option>
</SELECT>
</Body>
// C # Code
Protected void page_load (Object sender, system. eventargs E)
{
Public String gradeselect = string. empty;
Public String subjectselect = string. empty;
If (! (Ispostback ))
{
Gradeselect = request. querystring ["Grade"];
Subjectselect = request. querystring ["Course"];
}
}