Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple edit text field
    primarykey
    data
    text
    <p>Im trying to modify the following code so it can save for multiple edited text while at the moment this code only saving one (first) edited text ... could anybody please modify this code for me say for example: you modify it to save 3 or 4 edited text, and based on that I can add any number of text field I need. and onother thing to menstion when if you write in text fild, saved it and then refresh the page your written contents will still there same as if you try with the following code with one text field, I want this featear also applied when adding multiple text fields.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Allowing Users to Edit Multiple Text field and save the contents&lt;/title&gt; &lt;script type="text/javascript"&gt; function saveEdits() { //get the editable element var editElem = document.getElementById("edit"); //get the edited element content var userVersion = editElem.innerHTML; //save the content to local storage localStorage.userEdits = userVersion; //write a confirmation to the user document.getElementById("update").innerHTML="Edits saved!"; } function checkEdits() { //find out if the user has previously saved edits if(localStorage.userEdits!=null) document.getElementById("edit").innerHTML=localStorage.userEdits; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="checkEdits()"&gt; &lt;div id="edit" contenteditable="true"&gt; Here is the element's original content &lt;/div&gt; &lt;input type="button" value="save my edits" onclick="saveEdits()"/&gt; &lt;div id="update"&gt; Edit the text and click to save for next time&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thanks in Advance.</p> <p>this is what i've tried.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Allowing Users to Edit Multiple Text field and save the contents&lt;/title&gt; &lt;script type="text/javascript"&gt; function saveEdits() { //get the editable element var editElem = document.getElementById("edit"); //get the edited element content var userVersion = editElem.innerHTML; //save the content to local storage localStorage.userEdits = userVersion; // for new text field localStorage.userEdit1 = userVersion; //write a confirmation to the user document.getElementById("update").innerHTML="Edits saved!"; } function checkEdits() { //find out if the user has previously saved edits if(localStorage.userEdits!=null) document.getElementById("edit").innerHTML=localStorage.userEdits; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="checkEdits()"&gt; &lt;div id="edit" contenteditable="true"&gt; Here is the element's original content &lt;/div&gt; &lt;!--New text field --&gt; &lt;div id="edit" contenteditable="true"&gt; This is another text field. &lt;/div&gt; &lt;input type="button" value="save my edits" onclick="saveEdits()"/&gt; &lt;div id="update"&gt; Edit the text and click to save for next time&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload