CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 New Line in text area [Sorted]

Print topic Send  topic

Author Message
Wreckmaster

Posts: 48
Posted: 09/22/2012, 6:04 AM

Is there a way of inserting <br /> in a text area when the user hits enter on the key board to insert a new line.
Is it possible to put code in to the class file which would cause this in all text areas within the project ?.


View profile  Send private message
bannedone


Posts: 273
Posted: 09/24/2012, 7:02 PM

Hi

There are several ways to do this depending on what you want the effect to be

Do you want this <br/> to show in the text box?? If so, that is exactly what you will see in the input textbox and not see a new line genrated.

Or do you want this just to be what is put into the database for later display.

You could, as I know you are, use FCKeditor..
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
Wreckmaster

Posts: 48
Posted: 09/25/2012, 1:58 AM

In this case I am not using FCK .
I don' mind if the <br /> shows so long as its there.
Can you give some examples , I am sure this would benefit others too .

Thanks for your reply

Wreckmaster
View profile  Send private message
Stanj

Posts: 166
Posted: 09/27/2012, 2:33 AM

You can set the Content Type in the Data tab of of the Properties navigator to HTML from Text and it will display with the line break without the HTML code displayed.
_________________
Stan
St Petersburg Russia
View profile  Send private message
bannedone


Posts: 273
Posted: 09/27/2012, 6:13 AM

Hi

Do you want this to happen on the client side or server side??

On the server side in the before insert event and before update event for the text area do something like this.

$Container->yourtextarea->SetValue(str_replace("\n","<br/>",$Container->yourtextarea->GetValue()));

*Note: I did not specifically test for the proper search string. It could be \r instead of \n or both I cannot remeber off the top of my head which it is in a browser. But you can easily figure that out.

If on the client side, write some java script to do the same.

Something like this...

Create a function

function setBR(control){
element=control.id;
e=document.getElementById(element);
textarea=e.value;
textarea=textarea.replace("\n","<br/>"); //Same issue here as above. Figure out the proper search value.
e.value=textarea;
}

Now on the control's onkeyup event (the DOM function not the Sever event.. This is found on the format tab for the control at the bottom.) Put this call in: setBR(this)

I have not tested this, but I think what Stanj is saying will not work when you are inputting data into a textarea.

He is, however, correct when CCS displays the textarea.

Let me know which method worked for you.

Have Fun.
8-)


_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
bannedone


Posts: 273
Posted: 09/27/2012, 7:24 AM

I just tested it for you.. the search string should be "\r\n"

So try this
$Container->yourtextarea->SetValue(str_replace("\r\n","<br/>",$Container->yourtextarea->GetValue()));

for server side

and this for client side

textarea=textarea.replace("\r\n","<br/>");

_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
Wreckmaster

Posts: 48
Posted: 09/27/2012, 10:09 AM

Thank you so much for your time bannedone.
Works perfectly .

As this is an edit form only, I used the before update event with

$Container->yourtextarea->SetValue(str_replace("\r\n","<br/>",$Container->yourtextarea->GetValue()));

this adds the <br /> for new line and as StanJ suggested I set output to HTML .

Thanks again your great . 8-)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.