Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the output of this script I\'m working on. The object is to get

ID: 3544674 • Letter: I

Question

I need help with the output of this script I'm working on.  The object is to get a printout of the power input , as well as a SUBTOTAL of all of the POWER inputs listed at the bottom of the page, as well as the corresponding text listing (listed in the script).  I can get the power inputs, no problem.  But I can't get the SUBTOTAL or the corresponding TEXT to print under it.  Here's what I have so far:


<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<link rel="stylesheet" href="style.css">

<title>Ernest Tee's Kung Fu Panda Po Power Level</title>

<script type="text/javascript">

var power;

function getPowerLevel()

{ power=prompt("Enter Ernest's Po Power Level");

  document.getElementById("powerLevel").innerHTML=power;

}

function getTotal()

{

var total;

    total+=power;

if (total<0){

document.getElementById("newText").innerHTML = "Po eats too much noodle";

}

else if (total >=0 && total <=20)

{document.getElementById("newText").innerHTML = "Po reaches the training hall";

}

else if (total >=21 && total <=40)

{document.getElementById("newText").innerHTML = "Po reaches the student barracks";

}

else if (total >=41 && total <=60)

{document.getElementById("newText").innerHTML = "Po reaches the Peach Tree of Heavenly Wisdom";

}

else if (total >=61 && total <=80)

{document.getElementById("newText").innerHTML = "Po climbs the Wu Da Mountains";

}

else if (total >=81 && total <=100)

{document.getElementById("newText").innerHTML = "Po trains at the Pool of Sacred Tears";

}

else if (total >100)

{document.getElementById("newText").innerHTML = "Po defeats Tai Lung";

}

}

</script>

</head>

<body>

<header>

<h1>Ernest Tee's Kung Fu Panda<br>Po Power Level</h1>

</header>

<p>This page will prompt Ernest for Kung Fu Panda Po's power level (in number).<br>The program will convert the given input into Po's power metric.</p>

<p>

less than 0:  Po eats too much noodle<br>

0 to 20: Po reaches the training hall<br>

21 to 40:  Po reaches the student barracks<br>

41 to 60:  Po reaches the Peach Tree of Heavenly Wisdom<br>

61 to 80:  Po climbs the Wu Da Mountains<br>

81 to 100:  Po trains at the Pool of Sacred Tears<br>

Greater than 100:  Po defeats Tai Lung<br>

</p><br>

<h3>Click on the button below to enter Po's power level</h3>

<div id="container1">

<p><input type="button" value="Enter Ernest's Po Power Level"></p>

<p>Po's Power: <span id="powerLevel"> </span></p>

<p>Po's current power level: <span id="powerLevelTotal"> </span></p>

<p id="newText">  <br />

<br>

</div>

</body>


</html>

Explanation / Answer

hi ,

I forgot to copy the next steps in get Total ..    this part displays the powerLevelTotal...

function getTotal()

{
total=power;

prev = parseInt(document.getElementById("powerLevelTotal").innerHTML);
total = parseInt(prev) + parseInt(total);
document.getElementById("powerLevelTotal").innerHTML=total;


after this, you have your existinf if else logic .


Hope it Helps :)