zoukankan      html  css  js  c++  java
  • 仿百度

    页面:

     <input id="txtSchool" onkeyup="SetSchoolKeyUp('txtSchool', 'selSchool', 'hidSchool');" onfocus="SetSchoolFocus('txtSchool', 'selSchool', 'hidSchool');"  class="input2"/>
     <input id="hidSchool" type="hidden" value="" />
     <select id="selSchool" class ="pa left00" onclick="SetSchoolClick('txtSchool', 'selSchool', 'hidSchool');" multiple="multiple" style="display:none" >
     </select>

    JS:

    ///textid:文本框id
    ///selectid:选择框id
    ///hideid :隐藏域id
    
    ///实时刷新
    function SetSchoolKeyUp(textId, selectId, hideId) {
        if ($("#" + textId).val() == "") {
            $("#" + hideId).val("");
            $("#" + selectId).css("display", "none");
        } else {
            GetSchool(selectId, $("#" + textId).val());
            $("#" + selectId).css("display", "block");
        }
    }
    
    ///获取焦点
    function SetSchoolFocus(textId, selectId, hideId) {
        if ($("#" + textId).val() == "") {
            $("#" + hideId).val("");
            $("#" + selectId).css("display", "none");
        } else {
            GetSchool(selectId, $("#" + textId).val());
            $("#" + selectId).css("display", "block");
        }
    }
    
    function SetSchoolClick(textId, selectId, hideId) {
        $("#" + textId).val($("#" + selectId).find("option:selected").text());
        $("#" + hideId).val($("#" + selectId).val());
        $("#" + selectId).css("display", "none");
    }
    
    
    function GetSchool(selectId, textValue) {
        $.ajax({
            type: "post",
            dataType: "json",
            contentType: "application/json",
            async: true,
            url: "/asmxs/SYS/School/School.asmx/GetSchools",
            data: '{"strWhere":"","schoolName":"' + textValue + '"}',
            success: function (e) {
                var lists = e.d;
                var select = $("#" + selectId);
                select.children().remove();
                for (var i = 0; i < lists.length; i++) {
                    var mode = lists[i];
                    select.append("<option value=" + mode.SchoolID + ">" + mode.SchoolName + "</option>");
                }
            },
            error: function (e, x) {
                alert("操作失败!");
            }
        });
    }
  • 相关阅读:
    不要为自己找借口,你可以做到的--职场实用做人法则
    sql server 利用发布订阅方式实现数据库同步问题
    关于免费空间的寻找
    数据自定义格式化
    C++字符串string类常用操作详解(一)【初始化、遍历、连接】
    C++ 命名空间
    gcc/g++ 如何支持c11 / c++11标准编译
    正确的C++/C堆栈
    linux下清空c++ cin无效流的方式
    32位64位下各种数据类型大小的对比
  • 原文地址:https://www.cnblogs.com/xiaoqi742709106/p/4062123.html
Copyright © 2011-2022 走看看