asp.net 两级联动 asp.net两级联动(包含添加和修改)
人气:0想了解asp.net两级联动(包含添加和修改)的相关内容吗,在本文为您仔细讲解asp.net 两级联动的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:asp.net,两级联动,添加,修改,下面大家一起来学习吧。
<script language="javascript" type="text/javascript"> //科目数据初始化
var subcat = new Array();
subcat[0] = new Array('0', '请选择科目', '0');
subcat[1] = new Array('x1', '语文', 'x1yw');
subcat[2] = new Array('x2', '语文', 'x2yw');
subcat[3] = new Array('x3', '语文', 'x3yw');
subcat[4] = new Array('x4', '语文', 'x4yw');
subcat[5] = new Array('x5', '语文', 'x5yw');
subcat[6] = new Array('x6', '语文', 'x6yw');
subcat[7] = new Array('c5', '语文', 'c5yw');
subcat[8] = new Array('c6', '语文', 'c6yw');
subcat[9] = new Array('c7', '语文', 'c7yw');
subcat[10] = new Array('g1', '语文', 'g1yw');
subcat[11] = new Array('g3', '语文', 'g3yw');
subcat[12] = new Array('g4', '语文', 'g4yw');
subcat[13] = new Array('x1', '数学', 'x1sx');
subcat[14] = new Array('x2', '数学', 'x2sx');
subcat[15] = new Array('x3', '数学', 'x3sx');
subcat[16] = new Array('x4', '数学', 'x4sx');
subcat[17] = new Array('x5', '数学', 'x5sx');
subcat[18] = new Array('x6', '数学', 'x6sx');
subcat[19] = new Array('c5', '数学', 'c5sx');
subcat[20] = new Array('c6', '数学', 'c6sx');
subcat[21] = new Array('c7', '数学', 'c7sx');
subcat[22] = new Array('g1', '数学', 'g1sx');
subcat[23] = new Array('g3', '数学', 'g3sx');
subcat[24] = new Array('g4', '数学', 'g4sx');
subcat[25] = new Array('x1', '英语', 'x1yy');
subcat[26] = new Array('x2', '英语', 'x2yy');
subcat[27] = new Array('x3', '英语', 'x3yy');
subcat[28] = new Array('x4', '英语', 'x4yy');
subcat[29] = new Array('x5', '英语', 'x5yy');
subcat[30] = new Array('x6', '英语', 'x6yy');
subcat[31] = new Array('c5', '英语', 'c5yy');
subcat[32] = new Array('c6', '英语', 'c6yy');
subcat[33] = new Array('c7', '英语', 'c7yy');
subcat[34] = new Array('g1', '英语', 'g1yy');
subcat[35] = new Array('g3', '英语', 'g3yy');
subcat[36] = new Array('g4', '英语', 'g4yy');
subcat[37] = new Array('c5', '物理', 'c5wl');
subcat[38] = new Array('c6', '物理', 'c6wl');
subcat[39] = new Array('c7', '物理', 'c7wl');
subcat[40] = new Array('g1', '物理', 'g1wl');
subcat[41] = new Array('g3', '物理', 'g3wl');
subcat[42] = new Array('g4', '物理', 'g4wl');
subcat[43] = new Array('c5', '化学', 'c5hx');
subcat[44] = new Array('c6', '化学', 'c6hx');
subcat[45] = new Array('c7', '化学', 'c7hx');
subcat[46] = new Array('g1', '化学', 'g1hx');
subcat[47] = new Array('g3', '化学', 'g3hx');
subcat[48] = new Array('g4', '化学', 'g4hx');
subcat[49] = new Array('c5', '政治', 'c5zz');
subcat[50] = new Array('c6', '政治', 'c6zz');
subcat[51] = new Array('c7', '政治', 'c7zz');
subcat[52] = new Array('g1', '政治', 'g1zz');
subcat[53] = new Array('g3', '政治', 'g3zz');
subcat[54] = new Array('g4', '政治', 'g4zz');
subcat[55] = new Array('c5', '历史', 'c5ls');
subcat[56] = new Array('c6', '历史', 'c6ls');
subcat[57] = new Array('c7', '历史', 'c7ls');
subcat[58] = new Array('g1', '历史', 'g1ls');
subcat[59] = new Array('g3', '历史', 'g3ls');
subcat[60] = new Array('g4', '历史', 'g4ls');
subcat[61] = new Array('c5', '生物', 'c5sw');
subcat[62] = new Array('c6', '生物', 'c6sw');
subcat[63] = new Array('c7', '生物', 'c7sw');
subcat[64] = new Array('g1', '生物', 'g1sw');
subcat[65] = new Array('g3', '生物', 'g3sw');
subcat[66] = new Array('g4', '生物', 'g4sw');
subcat[67] = new Array('c5', '地理', 'c5dl');
subcat[68] = new Array('c6', '地理', 'c6dl');
subcat[69] = new Array('c7', '地理', 'c7dl');
subcat[70] = new Array('g1', '地理', 'g1dl');
subcat[71] = new Array('g3', '地理', 'g3dl');
subcat[72] = new Array('g4', '地理', 'g4dl');
subcat[73] = new Array('x1', '其它', 'x1qt');
subcat[74] = new Array('x2', '其它', 'x2qt');
subcat[75] = new Array('x3', '其它', 'x3qt');
subcat[76] = new Array('x4', '其它', 'x4qt');
subcat[77] = new Array('x5', '其它', 'x5qt');
subcat[78] = new Array('x6', '其它', 'x6qt');
subcat[79] = new Array('c5', '其它', 'c5qt');
subcat[80] = new Array('c6', '其它', 'c6qt');
subcat[81] = new Array('c7', '其它', 'c7qt');
subcat[82] = new Array('g1', '其它', 'g1qt');
subcat[83] = new Array('g3', '其它', 'g3qt');
subcat[84] = new Array('g4', '其它', 'g4qt');
//选择年级
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]);
}
}
}
//修改页面科目数据加载
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('全部科目', '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">请选择年级</option>
<option value="x1" <%=GradeSelect == "x1" ? "selected":"" %>>一年级</option>
<option value="x2" <%=GradeSelect == "x2" ? "selected":"" %>>二年级</option>
<option value="x3" <%=GradeSelect == "x3" ? "selected":"" %>>三年级</option>
<option value="x4" <%=GradeSelect == "x4" ? "selected":"" %>>四年级</option>
<option value="x5" <%=GradeSelect == "x5" ? "selected":"" %>>五年级</option>
<option value="x6" <%=GradeSelect == "x6" ? "selected":"" %>>六年级</option>
<option value="c5" <%=GradeSelect == "c5" ? "selected":"" %>>七年级</option>
<option value="c6" <%=GradeSelect == "c6" ? "selected":"" %>>八年级</option>
<option value="c7" <%=GradeSelect == "c7" ? "selected":"" %>>九年级</option>
<option value="g1" <%=GradeSelect == "g1" ? "selected":"" %>>高一</option>
<option value="g3" <%=GradeSelect == "g3" ? "selected":"" %>>高二</option>
<option value="g4" <%=GradeSelect == "g4" ? "selected":"" %>>高三</option>
</select>
<select name="Course" id="Course" class="input">
<option value="0">请选择年级</option>
</select>
</body>
//C#代码
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"];
}
}
加载全部内容