Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 9th, 2004, 11:14 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default 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
Reply With Quote
  #2 (permalink)  
Old June 9th, 2004, 11:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Reply With Quote
  #3 (permalink)  
Old June 9th, 2004, 11:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Reply With Quote
  #4 (permalink)  
Old June 9th, 2004, 11:31 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
Reply With Quote
  #5 (permalink)  
Old June 9th, 2004, 11:41 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
Reply With Quote
  #6 (permalink)  
Old June 9th, 2004, 11:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Reply With Quote
  #7 (permalink)  
Old June 9th, 2004, 11:57 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
Reply With Quote
  #8 (permalink)  
Old June 10th, 2004, 12:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Reply With Quote
  #9 (permalink)  
Old June 10th, 2004, 12:19 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab function + <textarea></textarea> Adam H-W HTML Code Clinic 0 April 24th, 2007 10:36 AM
Display text data in textarea from SQL query palvin Classic ASP Professional 13 November 30th, 2005 05:52 PM
Display text data in textarea from SQL query palvin Classic ASP Databases 0 November 29th, 2005 05:44 PM
Display data in textarea with select statement Alex_forever MySQL 6 April 27th, 2004 06:05 PM
TextArea microchip Classic ASP Databases 2 March 17th, 2004 11:19 AM



All times are GMT -4. The time now is 07:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.