 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 9th, 2004, 11:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
display vbCrLf's from textarea to textarea
Hello all
A bit stupid I feel!!
I am aware how to dispaly text from a text area on a page as page copy (using the replace function)
How do I display text inside a textarea, holding formatting? (text has come from a record set) All variations of 'what I thought would work' do not.
I am using the following function:
Function DisplayMemo(theText)
DisplayMemo = ""
on error resume next
DisplayMemo = CStr(theText)
if (len(DisplayMemo) > 0) Then
DisplayMemo = Replace(DisplayMemo, vbCrLf, "<br>", 1, -1, 1)
end if
End Function
calling it like:
<textarea cols=119 name=ownSubmitted rows=7>" & DisplayMemo(getInfo(0)) & "</textarea>
NOTE: getInfo(0) is a variable holding my value. Yes the value is there. It is showing the text I want, however the <br>'s are rendered inside the text area?
Thank you in advance
Damn, I feel even more stupid now Ive read this post
Wind is your friend
Matt
__________________
Wind is your friend
Matt
|
|

June 9th, 2004, 11:20 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Matt,
Try this code.
Code:
Function DisplayMemo(theText)
if (len(theText) > 0) Then DisplayMemo = Replace(theText, vbCrLf, "<br>")
End Function
Cheers!
_________________________
-Vijay G
 Strive for Perfection 
|
|

June 9th, 2004, 11:27 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Matt,
Code:
Function DisplayMemo(theText)
if (len(theText) > 0) Then DisplayMemo = Replace(theText, "<br>", vbCrLf)
End Function
I forgot to change that in Replace function. Please use this, if you want to replace all "<BR>"s with VBCrlf.
Cheers!
_________________________
-Vijay G
 Strive for Perfection 
|
|

June 9th, 2004, 11:31 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Vijay
I have tryed variations of the function and the way I have used it without success. I was pulling my hair out as your message came in, yes I will try that one (I believe I tryed it without the end parameters). It seems like a very simple objective, I have never had a need to show text inside another textarea before, have you? The text comes from a datastore, it's exact syntax inside the table is:
demo text and more <br><br> demo text <br><br> plus more etc
thanking you
Wind is your friend
Matt
|
|

June 9th, 2004, 11:41 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Wow - maybe my machine is just unhappy today, it didnt work either.
Would you agree my original function and yours are, from a 'end result' perspective - identical?
Obviously shorter in length, the "1, -1, 1)" parameters are all that different?
Should I shut down for the day and have a jack daniels?
Wind is your friend
Matt
|
|

June 9th, 2004, 11:53 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Matt,
I think the original one shouldn't be good. Coz once you assign something to your FUNCTION name within the same function that should return the control back to the calling function. So that should be the last line of you FUNCTION, when you want to return some value.
The last 3 parameters of REPLACE function as you did, are optional and decides what type of comparision is to be done like that. But it is enough in our case that replace function be called with default last 3 parameters, so I had skipped them.
Code:
<textarea name="txt1">demo text and more <br><br> demo text <br><br></textarea>
<textarea name="txt2"><%=Replace("demo text and more <br><br> demo text <br><br>","<br>",VBCRLF)%></textarea>
The first one has - "demo text and more <br><br> demo text <br><br>"
The second one has -
demo text and more
demo text
This works fine for me. Just hit the ghost in your system with a rod;).
_________________________
-Vijay G
 Strive for Perfection 
|
|

June 9th, 2004, 11:57 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Ok - i'm an idiot - problem solved, it was a case sensitivity issue. It wouldnt replace <br> with vbCrLf
because
<BR> was stored in my table
Incidently both functions work, think i'll still have stiff jack anyhow
Vijay - thank you kindly for your time
Wind is your friend
Matt
|
|

June 10th, 2004, 12:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Matt,
I too didnot think about that earlier.
Great to know that it is solved.
But remember to follow the same CASE while replace VBCRLF to <BR>s when you INSERT into DB and later replace <BR>s to VBCRLF when you retrieve too.
Cheers!
_________________________
-Vijay G
 Strive for Perfection 
|
|

June 10th, 2004, 12:19 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Indeed
We are supposwed to adhere to XML.... standards around here.
Now instead of throwing my machine from the 14th floor into
Darling harbour, I'll throw the person who handled the data
before me's machine - Mr upper case HTML guy, i'll find him.
Thanks for your time and have a nice day
Wind is your friend
Matt
|
|
 |