I'm trying to get data (taken from mongo) to display into a textarea.
It's purpose is so that I can edit data within the database without actually touching the database itself.
I can display the data within normal HTML tags but I'm pretty clueless on how to get it to display it within a textarea (or any other tags that allow me to edit and re-submit the new data)
I'm rendering with EJS, and so far, everything display correctly with
<%= text %>
I just need it to work within a editable text area
This should work:
<textarea id="yourTextArea"><%= text %></textarea>
Related
I am trying to render a data from webhook to a form label say "PRO®AIN" is retrieved to a form. But it is rendered as PRO®AIN where ® is considered as ®. I know I can use encoding by using & ; instead & but I cannot do this change to backend while updating this data.
My question is, how do we render the data to the html page by ignoring such cases. I would like to display as like from backend.
I wonder the same above text is rendered properly as like in grid
I have a webpage where user will enter his details and then on click of submit, I am invoking a service through ajax call for saving it in db. Then I capture the response from the service written using java REST webservices and display it in the webpage. I am displaying the message "Details saved successfully".This message is read from a properties file in my java service layer and passed back to the web page. I currently need to change font color to the text being returned.
I tried adding the following <font color="red">Details saved successfully</font> to my file data and the same text is passed from service layer. IN the web page I see that the font color is not rendered for the text and that the entire above text with html tags is getting displayed in webpage. I am using $scope.status=response string in js page and in html page, I am rendering as <div id="test">{{status}}</div>
Is there any way to render the html tag when we pass it as string from properties from service layer to js page. My goal is not to change the existing html code and have the html tag rendered when read from properties file and passed as string from services.
Thanks.
Letting the user submit data containing HTML that is rendered when displayed can be a security risk. Users can be very creative in the HTML code that they "inject" in your application. There are lot of sites where you may find more information about that vulnerability.
When you need to add some markup, you might look at alternative markup rendering methods, for example BBCode or MarkDown.
I'm creating a website that allows a user to enter some data into a form, and the form once submitted will return a JSON. My website has a header, a footer, etc. Right now, I'm displaying the JSON inside a div.
My problem: the JSON can potentially be very large. The user of my website would ideally be able to copy the JSON result and use it for other purposes. If the user tries to select the whole JSON via Ctrl+A, it will select all the text in my website, i.e., header and footer. If the user just wants to get the JSON (and it is very large), he/she will have to manually select the JSON.
Is there a HTML element that I can use to render the JSON in (instead of div) so that, when the cursor is focused on this element, it will allow Ctrl+A to just select all the text inside this element? Something similar to this: http://www.jsoneditoronline.org/
I've been looking for different HTML elements, such as pre, but they don't achieve my goal. Maybe I'm not using the right keywords to search in a search engine.
Thanks.
A textarea element will do the trick or add contenteditable="true" to any element and they will be able to select all that way as well. Additionally check out https://clipboardjs.com/ which will allow you to automatically copy content to the users clipboard for them.
Well, I have some paragraphs in my php that is coming from a database, and I want the user to have the ability to double click the text or press a button, edit the text, and then save it in database. Is it possible?
Sure you can.
All you need to do is put a submit button that whenever it is clicked you preview a textarea. Then you show the value from the database on the textarea (by SELECT on the SQL command) and then after the 'send' submit button (after the user finished editing) take the value the user wrote by the name of the textarea and put it instead of the text you previewed (INSERT INTO command).
You can avoid using a textarea by setting the contentEditable property to true or false on the element that contain the text.
For example, if the HTML is like :
<p id="sometext">This is the paragraph you cant to be able to edit</p>
You can use document.getElementById("sometext").contentEditable = true; in JS to make it editable - and document.getElementById("sometext").contentEditable = false; to reverse it.
Then you could for example retrieve the innerHTML of the element when done with editing, and send it via AJAX to a PHP processing page (updating into MySQL DB) ^^
Yes, you can. You'd need a textarea with submit button, and then you would take the contents of the textarea and use SQL update to update the database with the contents of the textarea.
A full answer is a tad to broad for Stack Overflow.
So I'm using ExtJS for a job I'm working and I'm trying to dynamically populate the textarea associated with the HTML editor with data based on what a user selects from a combo box. From what I've found, I can load the HTML editor with text using the defaultValue property. So if I'm going to populate it after the page loads, can I give it something like a datastore or is there a method I can call to set the text?
Just call foo.setValue("bar");, like with all form inputs.
http://www.extjs.com/deploy/dev/docs/source/Field.html#method-Ext.form.Field-setValue
http://www.extjs.com/deploy/dev/docs/?class=Ext.form.HtmlEditor