имя списка: представление списка «FAQ»: столбец «Все элементы»: столбец заголовка 2: столбец тела 3: отдел
Предполагается, что в одной и той же таблице дважды вставлена одна и та же таблица.вторая веб-часть отображает все записи.Первый скрыт и отображает только то, что возвращается из поиска.
В настоящее время оба списка не отображаются и результаты не заполняются, а также msgHTML и newFAQHtml
<style type="text/css">
.ms-listviewtable {display:none;} // hide all listviews on the page by css class
</style>
<script type="text/javascript">
$(document).ready(function() {
$(".ms-listviewtable").eq(1).show(); // show 2nd listview table - Existing Questions/Answers
});
function searchList(){
var list = $(".ms-listviewtable").eq(0); // select 1st listview table - Search Results
var searchInput = $("input[title=ListSearchText]"); // search box text
var listItems = $(".ms-listviewtable:eq(0) tr:not(.ms-viewheadertr)"); // rows of the items in 1st listview table
var results = 0; // search results flag
var searchCol = $("#sfield")[0].selectedIndex; // # of column in list to search - from dropdown
if ( searchInput.val() != "" )
{
var statusDiv = $("#searchStatus"); // div to show status of search
listItems.each(function() // for each item in our list
{
var cellValue = $(this).closest('tr').find('td:eq('+ searchCol + ')').text().toLowerCase(); //get text in cell, convert to lowercase to eliminate case-sensitivity
var row = $(this);
if (cellValue.indexOf( searchInput.val().toLowerCase() ) != -1) // does it match the search text
{
row.show();
results = 1;
}
else
{
row.hide();
}
});
var msgHtml = "<div style='font-size:10pt;color:black;font-weight:normal;margin-left:13px;'><br/>Your search did not return any results.</div>";
var newFAQHtml = "<div style='font-size:10pt;color:black;font-weight:normal;margin-left:13px;'><br/>Did our search return what your'e looking for? If not, you may <a href='javascript:OpenPopUpPage("https://Lists/FAQ/NewForm.aspx");'>enter a new submission</a>.</div>";
if (results > 0)
{
list.show();
list.find('.ms-viewheadertr').show();
statusDiv.html("Search results for: <b>" + searchInput.val() + "</b>");
}
else
{
list.hide();
list.find('.ms-viewheadertr').hide();
statusDiv.html("Search results for: <b>" + searchInput.val() + "</b>" + msgHtml);
}
searchInput.val("");
}
}
</script>
<div onkeydown="javascript:if (event.keyCode == 13) searchList()">
<span style="font-size: 10pt;color:black;font-weight:bold;">Please Select FAQ Category: </span>
<select id="sfield">
<option value=""></option>
<option value="Title">Question</option>
<option value="Body">Category</option>
<option value="Department">Answer</option>
</select>
<input type=”text” id=”sText” title="ListSearchText" />
<input type="button" id="btnSearch" value="Search" onclick="searchList();" />
<a href="https://Help.aspx">Clear Search</a><div>
<br/>
<div id="searchStatus" style="font-size:10pt;font:Tahoma;color:#385b98;width:100%;"></div>