Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count amount off HTMLTags in a textarea value

Status
Not open for further replies.

RayDance

Programmer
Mar 22, 2002
13
NL
I'm inserting large amounts off text in one textarea and it's HTML text. I use <hr /> for a page break, but now I want to know how many pages I have in one textarea. So I have to know the amount/count off the <hr /> TAGs. Does anybody know how I can count these <hr /> TAGs from the texarea value? It does'nt mather if it's in JavaScript or in Coldfusion. I know that I can make a function to do a ReFindNoCase, but I'm looking for a shorter way!
If you can help me.... thx!
 
Here's a way to do it in CF:

<cfset myText = &quot;This is my test</hr> I want to see how many </hr> times the </hr> tag shows up in this </hr> text. Will this work?</hr>&quot;>

<cfset eof = 1>
<cfset numTimes = 0>

<cfloop from=&quot;1&quot; to=&quot;#Len(myText)#&quot; index=&quot;i&quot;>
<cfset EndText = Find(&quot;</hr>&quot;,myText,eof)>
<cfif Find(&quot;</hr>&quot;,myText,eof)>
<cfset numtimes = numtimes + 1>
<cfelse>
<cfbreak>
</cfif>
<cfset eof = endText + 1>
</cfloop>

<cfoutput>It shows up #numTimes# in the text.</cfoutput>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top