How do I change my HTML/Java Script code from asking the user for the input from
ID: 3911899 • Letter: H
Question
How do I change my HTML/Java Script code from asking the user for the input from a pop up to a blank screen. Basically a single text area that takes inputsad does the same funtion
It should lok like something like this
My correct code looks like this, and I would like to keep it the same but i'm not sure how to change the pop up into a text field input.
<html>
<head>
<script type="text/javascript">
function load() {
var data = [];
while (true) {
var line = prompt("Enter course name, grade, and credit hours (e.g. CS320 B+ 4) ");
if (line == null || line == "") {
break;
}
var values = line.split(/s/);
data.push(values);
}
return data;
}
function display(data) {
var points = {
"A": 4,
"B+": 3.5,
"B": 3,
"C+": 2.5,
"C": 2,
"D": 1,
"F": 0,
"AF": 0,
"WF": 0
};
var hours = 0;
var table = document.getElementById('result');
table.innerHTML = "<tr><th>Course</th><th>Grade</th><th>Hours</th></tr>";
var sum = 0;
for (var i in data) {
var item = data[i];
table.innerHTML += "<tr><td>" +
item[0] + "</td><td>" +
item[1] + "</td><td>" + item[2] + "</td>";
sum += points[item[1]] * parseInt(item[2]);
hours += parseInt(item[2]);
}
var gpa = sum / hours;
var text = "<br/>Total grade points = " + sum;
text += "<br/>Number of hours = " + hours + "<br/>";
text += "GPA = " + gpa; //printing the output
document.getElementById('text').innerHTML = text;
}
</script>
</head>
<body>
<table id="result" border="1px" class="classy">
</table>
<span id="text"></span>
<script type="text/javascript">
data = load();
display(data);
</script>
</body>
</html>
GPA Calculator THL100 +3 PHL107A 3 EN0120 ?. 3 NTH245 A4 CSC221 AS Compute GPA Total # of grade points: 53 Total # of credit hours: 16 Grade Point Average 3625Explanation / Answer
Answer : Register an extra event with the button ComputeGpa so that when user clicks on the button ,an event is raised which clears all the text area automatically , example
//////////////////////////////
var tag = document.querySelector("button");
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.