/    Sign up×
Community /Pin to ProfileBookmark

how can I restrict the number of news in a ticker ?

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/&#21109;&#34220;&#20225;&#30011;&#25512;&#36914;&#37096;_&#31038;&#20869;&#20844;&#38283;/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>[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @dschmitt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...