Search This Blog

Sunday, September 22, 2013

FilterName for multiple columns for searching a Custom List

2. Add Content Editor Web part on it.
3. Add below script in Source Editor - See more at: http://www.go4sharepoint.com/Forum/render-failed-error-list-view-2203.aspx#sthash.1NGcmTtM.dpuf
2. Add Content Editor Web part on it.
3. Add below script in Source Editor - See more at: http://www.go4sharepoint.com/Forum/render-failed-error-list-view-2203.aspx#sthash.1NGcmTtM.dpuf


1. Add Content Editor Web part on it. (insert Custom List)
2. Add Script Editor and Paste below code

3. Add below script in Source Editor - See more at: http://www.go4sharepoint.com/Forum/render-failed-error-list-view-2203.aspx#sthash.1NGcmTtM.dpuf
<html>
<head>
  <script type="text/javascript">
      function RedirectUrl() {
        
          var tbCity = document.getElementById("tbSearchCity").value;
          var tbAdress = document.getElementById("tbSearchAddress").value;
          var tbstate = document.getElementById("tbState").value;
          var tbZIPCode = document.getElementById("tbZIPCode").value;
          var Query = "";
          if (tbCity != null && tbCity != "") {

              Query = "?FilterName=City&FilterMultiValue=*" + tbCity + "*";
          }
          if (tbAdress != null && tbAdress != "") {
              if (Query == "") {
                  Query = "?FilterName=Address&FilterMultiValue=*" + tbAdress + "*";
              }
              else {
                  Query = Query + "&FilterName=Address&FilterMultiValue=*" + tbAdress + "*";
              }
          }
          if (tbstate != null && tbstate != "") {
              if (Query == "") {
                  Query = "?FilterName=State&FilterMultiValue=*" + tbstate + "*";
              }
              else {
                  Query = Query + "&FilterName=State&FilterMultiValue=*" + tbstate + "*";
              }
          }
          if (tbZIPCode != null && tbZIPCode != "") {
              if (Query == "") {
                  Query = "?FilterName=Zip_x0020_Code&FilterMultiValue=*" + tbZIPCode + "*";
              }
              else {
                  Query = Query + "&FilterName=Zip_x0020_Code&FilterMultiValue=*" + tbZIPCode + "*";
              }
          }
         
          window.location.href = Query;
     
      }
</script>

</head>
<body>
    <table>
        <tr>
            <td>
                City
            </td>
            <td>
                <input type="text" id="tbSearchCity" />
            </td>
        </tr>
        <tr>
            <td>
                Address
            </td>
            <td>
                <input type="text" id="tbSearchAddress" />
            </td>
        </tr>
        <tr>
            <td>
                State
            </td>
            <td>
                <input type="text" id="tbState" />
            </td>
        </tr>
        <tr>
            <td>
                ZIP code
            </td>
            <td>
                <input type="text" id="tbZIPCode" />
            </td>
        </tr>
         <tr>
            <td>
                &nbsp;
            </td>
            <td>
               <input type="button" id="btnSearch" value="search" onclick="return RedirectUrl();" />  &nbsp;<input type="button" id="btnClear" value="Clear" onclick="window.location.href = '/sites/devloop/Pages/Location-Search.aspx'" />
            </td>
        </tr>
    </table>

</body>
</html>


No comments:

Post a Comment