0

I am aware that using URLs like http://site/Lists/MyList/AllItems.aspx?FilterField1=Title&FilterValue1=ExactTitle&FilterField2=Year&FilterValue2=ExactYear will display a filtered view showing Title=ExactTitle and Year=ExactYear.

I would like to create a page on site which will function as a search form and pass the Title and Year parameters to the URL in accordance with user input. Specifically:

  • How do I create a button (aptly titled "Filter Title & Year") which will pass both parameters entered into the Title-searchbox and the Year-searchbox?
  • Can I create a drop-down list for the year field and add it - rather than an editbox - to the page? If so, how?

Solutions not requiring access to SharePoint Designer are preferred, and an explanation for dummies will be greatly appreciated. Thank you very much!

tl;dr Wondering how I can build a custom search page which creates a filtered-in-advance view URL, in accordance with user input.

0

Your try with the connection properties of web part to filter the listview For how to use conncetion you can refer link

0

Insert a Script Editor Web part and insert HTML code for the UI + JavaScript code for the logic. Something like this (not tested):

<input type="text" id="titleSearchInput"/>

<select id="yearSearchInput">
    <option value="2015">2015</option>
    <option value="2016">2016</option>
    <option value="2017">2017</option>
</select>

<button type="button" onclick="goSearch()">Search</button>

<script type="text/javascript">
    function goSearch(){

       // 1. Get the HTML elements
       var titleSearchInput = document.getElementById("titleSearchInput");
       var yearSearchInput = document.getElementById("yearSearchInput");

       // 2. Get the values from these inputs
       var titleSearch = titleSearchInput.value;
       var yearSearch = yearSearchInput.options[yearSearchInput.selectedIndex].value;

       // 3. TODO: check if titleSearch/yearSearch are null
       //          + escape values

       // 4. Build the search URL
       var URL = "http://site/Lists/MyList/AllItems.aspx?FilterField1=Title&FilterValue1=" + titleSearch + "&FilterField2=Year&FilterValue2=" + yearSearch;

       // 5. Redirect to the URL
       window.location.href = URL;

       return false; // TO avoid a postback because of the click on the button
    }
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.