var MyDivs; var MyDivsCount; var i; var content;
var has_Focus = "none yet" ;
function createMyNewDiv() {
var MyNewDiv = document.createElement("div");
console.log('MyNewDiv = ' + MyNewDiv);
MyNewDiv.setAttribute("class", "MyDiv");
MyNewDiv.innerHTML = "<div class='MyDivHeader'></div> <textarea class='txt' rows='4' cols='12'> </textarea> <br>";
content = document.getElementById("divStretch");
content.appendChild(MyNewDiv);
dragElement(MyNewDiv);
var MyNewPre = document.createElement("pre");
console.log('MyNewPre = ' + MyNewPre);
MyNewPre.setAttribute("contenteditable", "true");
MyNewPre.setAttribute("class", "pasteInto");
var preList = document.querySelectorAll("pre");
content = document.getElementById("preDiv");
content.appendChild(MyNewPre);
}//ï»ż
As I create a new class=âcopyFromâ ,
I notify dragElement(MyNewDiv); that it exists ,
But â function saveItAll() â still thinks there is only 1 class=âcopyFromâ . (Because it only copies âtextarea 0â to âpre-area 0â).
So I think I need to notify Somebody that there is a new element in town .
If that is the problem , how do I notify the powers that manage such things ?
Thanks
I may be wrong here, but it seems like the issue is that your copyFrom variable doesnât have an up-to-date list of all the textareas on the page. Looking at the code that gets generated, your textareas donât have the copyFrom class on them, so how will the code know what element to get the values from?
Thanks Kirupa;
Your Help led me to realize that I donât even need âpreâ and âcopyIntoââ .
I can just use:
fromList[i].innerHTML = fromList[i].value ;
So that function now looks like:
<script>
var copyFromVar = "one"; var fromList; var intoList;
function saveItAll() {
var blankVar = "";
fromList = document.getElementsByClassName("copyFrom");
for (var i = 0; i < fromList.length; i++) {
fromList[i].innerHTML = fromList[i].value ;
}
}// ========================================
</script>
I am better understanding the diff between
.value and .iinerHTML .
Thanks
1 Like
Creating engaging and entertaining content for designers and developers since 1998.