I have a text area in html and a form to store the information in the database. When I click on submit, it supposed to take this text and save it in the database. For example:
"This is a text and this is a list:
1. number 1
2. number 2"
However, when I load the information from the database it looks like:
"This is a text and this is a list: 1. number 1 2. number 2"
How do I keep the layout of the textarea not changed (keep the spaces, lists, etc) without the need for the user to enter any tags.
It's being stored just fine in the database. You're outputting what was entered as plain text as HTML, and HTML ignores line breaks. You need to convert your \n characters to <br /> tags. PHP has a nl2br() function for this.
You could have them enter the data in a WSYWIG and do the work on your side to make sure it's always formatted properly - client-side users still won't have to see any tags, especially if you limit their editing options...
tinyMCE, nicEdit are two good editors
Related
Oracle apex version: 20.1
I have a form in which the user can copy and paste email chains into a rich text editor form field. The form field is based off a column in my table that is stored as a CLOB. As you can see here: Form Field Displaying Email the rich text editor does an amazing job at preserving the characters, indentations, and the image as well.
The problem is we save hundreds of these emails, so when we have to provide information to an outside source we have to include all of these emails. We obviously don't want to have to click into each one of these records and copy/paste the email into a file and send them one by one. So I created a report that can display all of them at once, then use a print feature to save the report as a PDf. The description column is of type: Remove HTML. Report Displaying Email (This is the same email but I also pasted the reply to the email on top)
As you can see it has problems when it runs into certain characters. Almost all apostrophes are replaced with either ’ or '. Bullets are replaced with • and greater/less than signs are replaced with >. My character test line of !##$%^&*(){}><?/ displays as !##$%^&*(){}><?/
Is there a better way to format all of these emails so they can be downloaded into one file (pdf)? How can I tell apex to leave all of those characters alone while still removing the html?
I have a form with a text area as one of the input fields. I want to store the user entered data. In the process I need to store the \n (enter key). But here the problem is in the DataBase (MySql) data is stored, but \n is not stored; i.e. data store as:
.
When I display the same data in the browser it shows in single line.
I need to split the data with \n and it should look like:
When I display the same data in the browser it shows in single line.
Yes, it would - because a newline in HTML doesn't get rendered as a newline. If you look at the raw HTML, I suspect you'll still see the line breaks... it's just that's not how it's rendered.
In order to represent line breaks in HTML, you need to use <br /> between lines, or something similar - or display it with a <pre> tag.
Basically, you need to format your raw text as HTML, however you decide to do that. If you're just dumping the HTML straight into your page, you may well find you already have issues if the text contains HTML tags - they should be escaped.
If you are seeing \n being stored in database, then you can write logic to include
<br/> tag while printing database values on your jsp.
I have a form with a text field that users input text into. They can use multiple lines, put in bold text, underlined text, etc., but the text, when saved to SQL Server doesn't have any formatting saved, just the text is saved. What is the best way to save the text with the HTML so that when it gets viewed by another user and pulled up from Sql Server the HTML is saved and the formatting is saved?
Ex.
hello
Paul
This would be saved as
helloPaul
you can't see it but there are bold and carriage return html tags rapped around the text
When receiving data from the user, on the server side code, use HTML encode to safely store the data:
var inputData = Server.HtmlEncode("<strong>some data input from user</strong>"); //insert your user input data variable here
Then when displaying the data in your cshtml page, decode the data to display it as the user entered it:
HttpUtility.HtmlDecode(saveUserDataFromDatabaseVariable);
All this is assuming you have a rich text editor being plugged into the input field. CKEditor and TinyMCE are good ones.
You can use a text editor. Take a look at CKEditor. It's free and easy to use :)
Can you post some code and more details?
I have had good success with CKEditor. It is customizable, and its content can easily be saved via postback to a standard asp:TextBox.
It is possible that the editor you are using is not actually updating the input/textarea that you are using, it may be cloning the text and drawing the formatting in an overlay. You can use developer tools, or javascript, to verify this by checking the value property of the input or textarea element. If it is being saved via AJAX or javascript the code may be using the textContent or innerText properties instead of innerHTML.
I used the richtexteditor dll that's free online. it gave me a wiziwig box that the user can edit texxt in.
I'm sure there must be a lot of posts answering my query, but I am just not able to find the correct post.
In my application user is entering free from description in the text area. but when data is saved and displayed on the next page, entire text is wrapped in to single para. I want whole text to be saved as user enters it along with line spaces and newlines, tabs etc.
please redirect me to correct post. Do i have to save textarea as blob?
Thanks
Your problem is that the text is entered in plain text, however, in HTML, extra spaces are removed, and all sorts of space are just displayed as a single space character. You have to either display the text in a <pre></pre> tag (ugly way) or reformat it using regular expression or other string processing methods to make an actual HTML.
I'm writing a Javascript program that pretty prints some input as HTML. As part of that pretty printing, I add some text that isn't part of the original input (such as annotations, line numbers, etc.) But when the user copies from the page, it's a bunch of garbled text that isn't valid in the original format. Is there a way to prevent the text I added from getting copied?
You can "steal" a solution from pastebin. They have two versions of code: 1 with pretty printing, and another below the pretty printed text in a scrollable textbox, code without pretty printing and other edits.