js获取页面所有搜索条件

    <div class="search">
        产品简码:@Html.TextBox("ProCode", "")
        产品名称:@Html.TextBox("ProName", "")
        产品风格:@Html.TextBox("StyleType", "")
        产品材质:@Html.TextBox("MaterialType", "")
        <input type="button" class="button" value="查询" id="cx" name="cx" onclick="load()" />
    </div> 

 

<script>

//js获取页面所有搜索条件
function GetSearchData(SearchDivID) {

    var ObjID= SearchDivID? SearchDivID: ".search"; //默认为类样式.search, <div  class="search">
    var data = {};
    var $SearchObj = $(ObjID);

    $SearchObj.children().each(function () {
        var name = $(this).attr('name');
        if (name) {
            var val = $(this).val();
            if (val) {
                data[name] = val;
            }
        }
    });

    return data;
}

 

 

 

 

    function getlist() {

        var data = GetSearchData();
        $.post("/Controller/View", data,
            function (data) {
                $("#ID").html(data);
            })

    }

 

  </script>

posted @ 2019-09-12 11:00  罪後忆支湮  阅读(624)  评论(0编辑  收藏  举报