"Johnboy" wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
: I'm creating a website that will have a page that lists current news
: items. The news items will be stored in a SQL Server database and will
: have basically two fields, the date and the news blurb . . . On the
: main page of the site, I want to have a box that shows "Current News"
: and only pulls the first 7 or so words from the news blurb followed by
: a ... [more] where [more] is a link to the current news page.
:
: For example, the database entry may be something like this:
:
: 5/12/05
: Chicken Little reports sky is falling. Earlier today Mr. Little was
: struck in the head by an unidentified object and immediately announced
: the sky was falling.
:
: So on the main page of the of the site it would say:
:
: Current News:
: 5/12/05 Chicken Little reports sky is falling. Earlier ... [more]
:
: Is there some sort of Trim function in ASP that I could use to count
: the number of spaces in an article and if Less than 7 print the whole
: thing, or if more than 7 trim all characters after the 7th space?
:
: Any info would be greatly appreciated.
My little version... (the last line is pretty long)
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
function getPos(d, a)
dim char, count, pos
char = chr(32) : count = 0
pos = instr(1, article, char)
do until count = 7
count = count + 1
if pos = 0 then
exit do
else
pos = instr(pos + 1, article, char)
end if
loop
getPos = pos
end function
dim articleDate, article, p, preview, fullview
articleDate = #5/12/05#
article = "Chicken Little reports sky is falling. Earlier today Mr. Little
was struck in the head by an unidentified object and immediately announced
the sky was falling."
p = getPos(articleDate, article)
if p = 0 then
Response.Write articleDate & " " & article
else
preview = left(article,p)
fullview = mid(article,p)
Response.Write articleDate & " " & left(article,p) & "<span
id=""ellipse""> ... </span><span id=""article"" style=""cursor: pointer;
color: blue"" onmouseover=""this.style.backgroundColor='#eef'""
onmouseout=""this.style.backgroundColor='#fff'""
onclick=""document.getElementById('ellipse').inner HTML='';
this.style.cursor='text'; onmouseover=''; this.style.color='#000';
this.innerHTML='" & fullview & "'"">[more]</span>"
end if
%>
http://kiddanger.com/lab/morearticle.asp
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp