﻿var s = document.getElementById;
function getgrade() {
    s("grade").options.length = 0;
    s("grade").add(new Option('年级', ''));
    var myRequest = new Request.JSON({
        method: 'post',
        url: '/Handle/Colltrol.asmx/BindGrade',
        data: '{StageValue:' + s("stage").value + '}',
        onSuccess: function(data, text) {
            data.d.each(function(item, i) {
                if (window.navigator.userAgent.indexOf("MSIE") > 0) {
                    var o = new Option(item.Value, item.Key);
                    s("grade").add(o);
                } else {
                    s("grade").insertBefore(new Option(item.Key, item.Value), item.Value);
                }

            });

        }
    }).send();
    getterm();
}
function getterm() {
    s("term").options.length = 0;
    s("term").add(new Option('学期', ''));
    var myRequest = new Request.JSON({
        method: 'post',
        url: '/Handle/Colltrol.asmx/BindTerm',
        data: '',
        onSuccess: function(data, text) {
            data.d.each(function(item, i) {
                if (window.navigator.userAgent.indexOf("MSIE") > 0) {
                    var o = new Option(item.Value, item.Key);
                    s("term").add(o);
                } else {
                    s("term").insertBefore(new Option(item.Key, item.Value), item.Value);
                }

            });

        }
    }).send();
    getedition();
}
//(int Stage, int Grade, int Term, int Subject)
function getedition() {
    s("edition").options.length = 0;
    s("edition").add(new Option('教材', ''));
    var myRequest = new Request.JSON({
        method: 'post',
        url: '/Handle/Colltrol.asmx/BindEdition',
        data: '{Stage:' + s("stage").value + ',Grade:' + s("grade").value + ',Term:' + s("term").value + ',Subject:1303}',
        onSuccess: function(data, text) {
            data.d.each(function(item, i) {
                if (window.navigator.userAgent.indexOf("MSIE") > 0) {
                    var o = new Option(item.Value, item.Key);
                    s("edition").add(o);
                } else {
                    s("edition").insertBefore(new Option(item.Key, item.Value), item.Value);
                }

            });

        }
    }).send();
    getunit();
}
//public List<KeyValuePair<Guid, string>> BindUnit(int Stage, int Grade, int Term, int Subject, int Edition)
function getunit() {
    s("unit").options.length = 0;
    s("unit").add(new Option('单元', ''));
    var myRequest = new Request.JSON({
        method: 'post',
        url: '/Handle/Colltrol.asmx/BindUnit',
        data: '{Stage:' + s("stage").value + ',Grade:' + s("grade").value + ',Term:' + s("term").value + ',Subject:1303,Edition:' + s("edition").value + '}',
        onSuccess: function(data, text) {
            data.d.each(function(item, i) {
                if (window.navigator.userAgent.indexOf("MSIE") > 0) {
                    var o = new Option(item.Value, item.Key);
                    s("unit").add(o);
                } else {
                    s("unit").insertBefore(new Option(item.Key, item.Value), item.Value);
                }

            });

        }
    }).send();
    getchapter();
}
// public List<KeyValuePair<Guid, string>> BindChapter(int Stage, int Grade, int Term, int Subject, int Edition, Guid Unit)
function getchapter() {
    s("chapter").options.length = 0;
    s("chapter").add(new Option('章节', ''));
    var myRequest = new Request.JSON({
        method: 'post',
        url: '/Handle/Colltrol.asmx/BindChapter',
        data: '{Stage:' + s("stage").value + ',Grade:' + s("grade").value + ',Term:' + s("term").value + ',Subject:1303,Edition:' + s("edition").value + ',Unit:"' + s("unit").value + '"}',
        onSuccess: function(data, text) {
            data.d.each(function(item, i) {
                if (window.navigator.userAgent.indexOf("MSIE") > 0) {
                    var o = new Option(item.Value, item.Key);
                    s("chapter").add(o);
                } else {
                    s("chapter").insertBefore(new Option(item.Key, item.Value), item.Value);
                }

            });
        }
    }).send();
}

