<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Eachqipageselect.ascx.cs" Inherits="Mvcb2b.admin.controls.news.Eachqipageselect" %>
<div id="qi_pageclass" class="liveclass">
<select id="eachqi" name="eachqi"><%=select1%></select>
<select id="eachpage" name="eachpage"><%=select2%></select>版
</div>
<script type="text/javascript"> 
   //创建单个option
    function opt(sel, txt, value, issel) {  //opt--------opt
        var op = document.createElement("option");
        op.value = value;
        op.text = txt;
        if (issel==1)
            op.setAttribute("selected", "selected");
        sel.options.add(op);
    }
    
    function Optionadd(pid, sel, nowid, fileurl) {  //pid为qiid ,sel,nowid现在正在的nowid----创建多个option
        //分类开始载入
        $.ajax({
            type: "POST",
            url: fileurl, 
            dataType: "json",
            data: { "qiid": "" + pid + "" }, //p传输的参数
            success: function(json) {
                if (json != 0) {
                    var issel = 0;
                    for (i = 0; i < json.classtable.length; i++) { //json为回传的数据；"classtable"表名在回传的json数据
                        issel = 0
                        if (json.classtable[i].id == nowid) {
                            issel = 1;
                        }
                        opt(sel, json.classtable[i].classname, json.classtable[i].id, issel); //opt--------opt
                    }
                }

            }, error: function(json) { alert("error-$.ajax" + json); }
        });
        //分类载入数据完        
    }

    $(document).ready(function() { 
        var editionid=<%=Editionid%>;
        var qiid=<%=Qiid%>;
        var fileurl="jquery/Eachqipage.aspx";
        sel = document.getElementById("eachpage");
        opt(sel, "请选择", "", 0); //opt--------opt
        Optionadd(qiid,sel,editionid,fileurl);
        
        $("#eachqi").change(function() {//这里是正式变化;
                    
                    sel.options.length = 0;
                    opt(sel, "请选择", "", 0); //opt--------opt
                     
                    var tempv = this.options[this.selectedIndex].value;
                    if (tempv != "") {
                        Optionadd(tempv,sel,editionid, fileurl);
                    }
       });
       /*加载完*/
    });
    
    
</script>


