• 根据值设置select的选中项


    $('.selector').attr("checked", true);
                <s:iterator value="jobSelect" id="jobLink2">
                      <s:iterator value="jobLink2" id="job2">                
                      var arr = $('.selector');
                      var a = ${job2.id};
                      $('.selector').each(function(){
                       
                         if($(this).val()== ${job2.id}){
                           $(this).attr("checked", true);
                         }
                   });
                     </s:iterator>
                </s:iterator>

    AJAX绑定Select下拉框的选项:

    方法一:

    <select id="TypeStr" />
         function BindDropDownList() {
                $("#TypeStr").html("");
                $.getJSON("NoticeHandler.ashx?bz=BindDropDownList", null, function (json) {
                    $.each(json, function (i,val) {
                        $.each(val,function(){
                            var a = this.id + this.typestr;
                            $("#TypeStr").append($("<option></option>").val(this.id).html(this.typestr))
                        })
                    });
                });
                $("<option></option>").val("").html("").appendTo("#TypeStr");
            }

    获取选中的文本值:

    var selT = $('#TypeStr option:selected').text();
    context.Response.Write(EDU.COMMON.PublicMethod.userjsondata("select * from ERPGongGaoType order by orderby "));

    备注:

     //StringBuilder sb = new StringBuilder();
                    //DataTable dt = new DataTable();
                    
                    //if (dt == null)
                    //    return;
                    //if (dt.Rows.Count == 0)
                    //{
                    //    return;
                    //}
                    //else
                    //{
                    //    sb.Append("[");
                    //    for (int i = 0; i < dt.Rows.Count; i++)
                    //    {
                    //        sb.Append("{"ID":"" + dt.Rows[i]["ID"].ToString() + "","Name":"" + dt.Rows[i]["Name"].ToString() + "","Age":" + dt.Rows[i]["Age"].ToString() + ","Tel":"" + dt.Rows[i]["Tel"].ToString() + ""},");
                    //    }
    
                    //    sb.Remove(sb.Length - 1, 1);
                    //    sb.Append("]");
                    //}
    
                    //context.Response.ContentType = "application/json";
                    //context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                    //context.Response.Write(sb.ToString());

    方法二:用LigerUI:

    var type=<%=EDU.COMMON.PublicMethod.GetSelectJson(EDU.DBUtility.DbHelperSQL.GetDataTable("SELECT id,typestr as text FROM [ERPGongGaoType] order by orderby")) %>;

    typeS = $("#TypeStr").ligerComboBox({
    data: type,
    });

    //获取值

    if(typeS != null){
    var selT = typeS.getText();
    if (selT != "") {
    where += " And TypeStr = '" + selT + "'";
    }
    }

  • 相关阅读:
    介绍一个小工具 Linqer
    wcf系列5天速成——第一天 binding的使用(1)
    wcf系列5天速成——第二天 binding的使用(2)
    wcf系列学习5天速成——第三天 事务的使用
    iptables 使用
    rsync 文件.数据同步
    Nginx打开目录浏览功能
    linux 添加开机启动
    watch 命令
    python 命令行处理
  • 原文地址:https://www.cnblogs.com/kennyliu/p/4027015.html
Copyright © 2020-2023  润新知