I have a var word_matching this variable should is used for storing a string of HTML. The problem is that the string is not getting updated:
if(!htmlGenerated)
{
word_matching.innerHTML = '';
console.log("generating textarea");
// create textarea
word_matching.innerHTML = '<textarea id="html" value=';
console.log(word_matching.innerHTML);
// create key inputs
for (let i = 0; i < elArray.length; i++)
{
word_matching.innerHTML += '<div id="s'+i+'"class="draggyBox-small">'+elArray[i]+'</div>\n'
}
// create description inputs
for (let i = 0; i < dlArray.length; i++)
{
word_matching.innerHTML += '<table id="tablestyle"><td >\n \t\t<div id="t'+i+'"class="ltarget"></div>\n \t</td >\n \t<td id="d2">'+dlArray[i]+'</td >\n </tr>\n</table>'
}
word_matching.innerHTML += '<div id = "program1" style="border: 1px solid #EB0D1B; width: 360px; font-family: courier; font-size: 100.5%; margin: 0px auto; border: 1px; text-align: center; margin-top: 5px;"> <span style="padding: 3px"> <button id ="one" class="button" type="button" onClick="one()">Show Answer</button> <button id = "resetButton" class="button" type="button" onClick="reset()">Reset</button><button id = "renderHTMLButton" class="button" type="button" onClick="render_html()">Render html</button> <span id = "audio" style=""> <a href="" title="Turns Text-to-Speech Output On or Off" class="menulink" style="text-decoration: none;"><img id="bg" src="audioOff.png" height="30" width="30" style="margin-bottom:-10px; padding-bottom:-20px;"/> </a> </span> </span> </div> </div></div>">';
htmlGenerated = true;
console.log("________ word matching _________");
console.log(word_matching.innerHTML);
console.log("________ word matching _________");
}
everything after the second initialization works. The code below prints out a blank line
// create textarea
word_matching.innerHTML = '<textarea id="html" value=';
console.log(word_matching.innerHTML);
The code below
console.log("________ word matching _________");
console.log(word_matching.innerHTML);
console.log("________ word matching _________");
prints out
________ word matching _________
Section5_3.html:131
<div id="s0" class="draggyBox-small">k1</div>
<div id="s1" class="draggyBox-small">k2</div>
<table id="tablestyle">
<tbody>
<tr>
<td>
<div id="t0" class="ltarget"></div>
</td>
<td id="d2">d1</td>
</tr>
</tbody>
</table>
<table id="tablestyle">
<tbody>
<tr>
<td>
<div id="t1" class="ltarget"></div>
</td>
<td id="d2">d2</td>
</tr>
</tbody>
</table>
<div id="program1" style="border: 1px solid #EB0D1B; width: 360px; font-family: courier; font-size: 100.5%; margin: 0px auto; border: 1px; text-align: center; margin-top: 5px;"> <span style="padding: 3px"> <button id="one" class="button" type="button" onclick="one()">Show Answer</button> <button id="resetButton" class="button" type="button" onclick="reset()">Reset</button><button id="renderHTMLButton" class="button" type="button" onclick="render_html()">Render html</button> <span id="audio" style=""> <a href="" title="Turns Text-to-Speech Output On or Off" class="menulink" style="text-decoration: none;"><img id="bg" src="audioOff.png" height="30" width="30" style="margin-bottom:-10px; padding-bottom:-20px;"> </a> </span> </span> </div> ">
________ word matching _________
I've tried printing out the line. Is there an error in this code?