My JavaScript code inside a Django template is not responding. What should I do?
This is what's within the <script>
tag:
var pageStrucVal = {{ pagestruc }};
if (pageStrucVal >= 82){
var pageWarn = ["Brilliant, your site's structure and design is awesome and rocking. <gold>RockingStructure</gold>", 'pp']
}
else if ( pageStrucVal >= 72){
var pageWarn = ["Nice, your site's structure and design is suitable", 'pp']
}
//other conditions...
console.log(pageWarn);
document.getElementById(pageWarn[1]).appendChild(document.createElement('p')).innerHTML = (pageWarn[0]);
Is
document.getElementById(pageWarn[1]).appendChild(document.createElement('p')).innerHTML = (pageWarn[0]);
written correctly and in the right place?
Here's a snippet of the HTML:
<div class='plusNdefects' id='moredetails'>
<h1>Good Aspects and Plus Points.</h1>
<p class='details'>Here are some awesome good aspects...</p>
//more HTML code...
</div>
<div class='plusNdefects'>
<h1>Disabilities and Improvements.</h1>
<p class='details'>These are some disabilities...</p>
//more HTML code...
</div>
'pp' and 'dd' represent the IDs where I intend to display the messages - 'pp' for plus points and 'dd' for defects.