zoukankan      html  css  js  c++  java
  • JS级联下拉框

    //Ajax级联获取SDK
    function GetDropDownList(parent_ddlID, fill_dllID, url, param) {
        this.pId = parent_ddlID;  //主下拉框name
        this.cId = fill_dllID;    //级联下拉框name
        this.URL = url;           //获取数据路径
        this.Paramer = param;     //参数
    }
    GetDropDownList.prototype.Inits = function (current) {
        var $ddl = $("select[name$=" + this.pId.toString() + "]");
        var $ddlSDKs = $("select[name$=" + this.cId.toString() + "]");
        $ddl.focus();
        $ddl.bind("change keyup", function () {
            if ($(this).val() != "0") {
                current.loadSDKList(current, $("select option:selected").val());
                $ddlSDKs.fadeIn("slow");
            } else {
                //$ddlSDKs.fadeOut("slow");
                $ddlSDKs.children("option").remove();
                $ddlSDKs.append($("<option></option>").val("0").html("不限"));
            }
        });
    }
    GetDropDownList.prototype.loadSDKList = function (current, selectedItem) {
        $.ajax({
            type: "get",
            url: this.URL,
            data: this.Paramer + "=" + selectedItem,
            dataType: "json",
            async: true,
            success: function (ret) {
                current.printSDKList(ret);
            }
        });
    }
    GetDropDownList.prototype.printSDKList = function (data) {
        $("select[name$=" + this.cId.toString() + "] > option").remove();
        for (var i = 0; i < data.length; i++) {
            $("select[name$=" + this.cId.toString() + "]").append(
                            $("<option></option>").val(data[i].Value).html(data[i].Text)
                       );
        }
    }

    //调用

    //var d = new GetDropDownList('主下拉框name', '级联下拉框name', '获取数据路径', '传递给调用路径的参数');
    //d.Inits(d);

    GetDropDownLis

  • 相关阅读:
    Maven插件之portable-config-maven-plugin(不同环境打包)
    redis
    MySQL之group_concat 配合substring_index查询
    Jmeter执行测试计划同时监听服务器性能PerfMon Metrics Collector
    【转】证书和编码
    [转]SSL/TLS协议运行机制的概述
    OC—MVC框架图解
    安卓intent
    day8---多线程socket 编程,tcp粘包处理
    day7---socket
  • 原文地址:https://www.cnblogs.com/hucaihao/p/3554688.html
Copyright © 2011-2022 走看看