I have a script for a news ticker that displays date and title of all news in a SharePoint list (see code below).
Rather than displaying the info for all the news articles in the list I would like display only the first 3 news articles in the list.
How do I need to modify the code below to see only the first three news articles in the ticker?
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”ja” lang=”ja”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<meta http-equiv=”Content-Style-Type” content=”text/css” />
<meta http-equiv=”Content-Script-Type” content=”text/javascript” />
<script type=”text/javascript” src=”../jQuery/jquery-1.3.2.min.js”></script>
<script type=”text/javascript” src=”../jQuery_scroller/jquery.li-scroller.1.0.js”></script>
<link rel=”stylesheet” href=”../jQuery_scroller/li-scroller.css” type=”text/css” media=”screen” />
</head>
<body>
<script type=”text/javascript”>
var URL_NEWS = ‘http://pws.ty.chugai-pharm.co.jp/’
+ ‘sites/ResearchPC-Dpt/創薬企画推進部_社内公開/Detlef/news/’;
var URL_BONE = URL_NEWS + ‘Lists/Bone/’ ;
$(document).ready(function() {
var soapEnv =
“<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org/soap/envelope/’>
<soapenv:Body>
<GetListItems xmlns=’http://schemas.microsoft.com/sharepoint/soap/’>
<listName>Bone</listName>
<viewFields>
<ViewFields>
<FieldRef Name=’Title’ />
</ViewFields>
</viewFields>
</GetListItems>
</soapenv:Body>
</soapenv:Envelope>”;
var test=function repeat(){
$.ajax({
url: URL_NEWS + “_vti_bin/lists.asmx”,
type: “POST”,
dataType: “xml”,
data: soapEnv,
complete: processResult,
contentType: “text/xml; charset=”utf-8″”
});
} //end repeat
function processResult(xData, status) {
var liHtml = ‘<li><span></span><a href=”#” ‘
+ ‘onclick=”window.open(”
+ URL_BONE
+ ”, ”, ‘return false’);”>Bone News</a></li>’;
$(xData.responseXML).find(“z\:row”).each(function() {
liHtml = liHtml + ‘<li><span>’ + $(this).attr(“ows_Date”).substr(0, 10) + ‘</span>’
+ ‘<a href=”#” ‘
+ ‘onclick=”window.open(”
+ URL_BONE + ‘DispForm.aspx?ID=’ + $(this).attr(“ows_ID”)
+ ”, ”, ”);”>’
+ $(this).attr(“ows_Title”) + “</a></li>”;
}); // alert(xData.responseText); alert(URL_NEWS); alert(URL_BONE); alert(liHtml)
$(“ul#ticker01”).html(liHtml).liScroll();
} //end process result
repeat();
});// end ready
</script>
<ul id=”ticker01″>
</ul>
</body>
</html>