0

Hello Every one, 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.

<html>
<head>
<title>Allowing Users to Edit Multiple Text field and save the contents</title>
<script type="text/javascript">
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;
}
</script>
</head>
<body onload="checkEdits()">

<div id="edit" contenteditable="true">
Here is the element's original content
</div>

<input type="button" value="save my edits" onclick="saveEdits()"/>

<div id="update"> Edit the text and click to save for next time</div>

</body>
</html>

Thanks in Advance..

1
Contributor
1
Reply
2
Views
4 Years
Discussion Span
Last Post by ssfox
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.