Thursday, 15 June 2017

Search On ListViewWebPart

Search On ListVIewWebPart Using Javascript

Copy and Paste below given script in CQWP

<script type="text/javascript">
    function RedirectUrl() {
        var tb = document.getElementById("tbSearch").value;
        var cs = document.getElementById("sfield").value;
        var url = "";

        if (tb != "") {
            if (cs == "Column2" || cs == "Column3" || cs == "Column4" || cs == "Column5") {
                url = "FilterField1=" + cs + "&FilterValue1=" + tb;
                window.location.href = "AllItems.aspx?" + url;
            }
            else {
                url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
                window.location.href = "AllItems.aspx?" + url;
            }
        }
        else {
            return false;
        }
    }
    function ClearUrl() {
        window.location.href = "AllItems.aspx";
    }
        </script>Search Field:
<select id="sfield"><option value="FirstName">FirstName</option><option value="FirstName">LastName</option><option value="Company">Department</option><option value="Email">Email</option></select>   Search text:
<input id="tbSearch" type="text"/><input id="btnSearch" onclick="return RedirectUrl();" type="button" value="Search"/><input id="btnClear" onclick="return ClearUrl();" type="button" value="Clear"/>​​​​​




No comments:

Post a Comment