Here is the code snippet I'm working with:
//Header container - summary info
var header = document.getElementById("Editsubmission");
var cont1 = document.createElement('div');
var cont2 = document.createElement('div');
cont1.textContent = "Your submission will be sent to: " + variable1;
cont2.textContent = "Reporting back to: " + variable2;
header.appendChild(cont1);
header.appendChild(cont2);
I am attempting to populate dynamically created DIV elements with text based on selections made in list boxes (variable1 and variable2). However, I am encountering an issue where new text gets appended to the DIV every time a different option is chosen before form submission. I need the old text to be cleared before adding new text. It seems like 'appendChild' might not be the right method to use. Any advice on how to achieve this?