473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I display a specific amount of words?

Hi. I have an ASP app that allows administrators to add articles to a
database for viewing by the public. What I want to do is display a summary
of the article and give the user the visitor to the website the option to
click "more..." to view all of the article.

Can anyone give me some tips or possibly point me to code that would help me
achieve this? Any help would be greatly appreciated.

Thanks
Aug 10 '06 #1
4 2316

Lisa wrote:
Hi. I have an ASP app that allows administrators to add articles to a
database for viewing by the public. What I want to do is display a summary
of the article and give the user the visitor to the website the option to
click "more..." to view all of the article.

Can anyone give me some tips or possibly point me to code that would help me
achieve this? Any help would be greatly appreciated.
1. Provide an additional input in the "add_articles" page so that
administrators can submit an abstract. Store that in a separate field
in the db and display only the abstract on the page to start with...
2. Use the Left() function to pick up the first 100/200/500 or whatever
characters followed by <a href="somelink">...more</a>
3. Use the split function to pick up the first x number of words...
<%
summary = split(article," ")
For i = 0 To 100 'number of words
Response.Write summary(i) & " "
Next

Option 1 is the one I use. That way, the contents of the summary are
under the contol of the admin/editor.

--
Mike Brind

Aug 10 '06 #2

Mike Brind wrote:
Lisa wrote:
Hi. I have an ASP app that allows administrators to add articles to a
database for viewing by the public. What I want to do is display a summary
of the article and give the user the visitor to the website the option to
click "more..." to view all of the article.

Can anyone give me some tips or possibly point me to code that would help me
achieve this? Any help would be greatly appreciated.

1. Provide an additional input in the "add_articles" page so that
administrators can submit an abstract. Store that in a separate field
in the db and display only the abstract on the page to start with...
2. Use the Left() function to pick up the first 100/200/500 or whatever
characters followed by <a href="somelink">...more</a>
3. Use the split function to pick up the first x number of words...
<%
summary = split(article," ")
For i = 0 To 100 'number of words
Response.Write summary(i) & " "
Next
Of course, with options 2 and 3, you would have to add code to check
that there are sufficient characters/elements to cover your selected
maximum number, otherwise you'll get errors.

Aug 10 '06 #3

"Lisa" <li@morespam.comwrote in message
news:12*************@corp.supernews.com...
Hi. I have an ASP app that allows administrators to add articles to a
database for viewing by the public. What I want to do is display a summary
of the article and give the user the visitor to the website the option to
click "more..." to view all of the article.

Can anyone give me some tips or possibly point me to code that would help
me
achieve this? Any help would be greatly appreciated.

Thanks

Function GetFirstNWords(Source, N)

Dim rgx : Set rgx = New RegExp
Dim oMatches

rgx.Pattern = "(?:\w+\s*){0," & N & "}"

Set oMatches = rgx.Execute(Source)

GetFirstNWords = oMatches(0).Value

End Function

Response.Write GetFirstNWords(sSource, 100)

Anthony.
Aug 10 '06 #4
Thanks for the suggestions!

"Lisa" <li@morespam.comwrote in message
news:12*************@corp.supernews.com...
Hi. I have an ASP app that allows administrators to add articles to a
database for viewing by the public. What I want to do is display a summary
of the article and give the user the visitor to the website the option to
click "more..." to view all of the article.

Can anyone give me some tips or possibly point me to code that would help
me
achieve this? Any help would be greatly appreciated.

Thanks


Aug 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: aatish19 | last post by:
Write a program that asks the user to input any amount as an integer number and display it in words Sample output: Enter any amount : 4562 Four thousend five hundred sixty two
5
by: CES | last post by:
All, I was hoping that someone might be able to help me with a few questions on Aligning Block Elements properly... Basically I have a row that has a fixed width of 900px. Within the row their is...
1
by: Jimmy Stewart | last post by:
Is there a way to set up a combo box so that when the user clicks the arrow, the list is populated with info from a specific field from a table but once they select an option, data from another...
8
by: Haines Brown | last post by:
I want a hot text string to display an image only when hovered. In the body: .... <a id="link-a" href="#nogo"> <img id="photo" src="..." />hot text </a> ....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.