Reputation: 1
I have quite a simple problem, but since I'm new to programming I really would like your help.
So basically I have a small HTML/php textboxes on my site where student can fill in answers. I want a for loop to compare these answers to a correct answers and see it there is a match.
What I'm trying to do:
so here is what I have so far:
const Student_Answers_1a = document.getElementsById("Antwoord1a");
const Student_Answers_1b = document.getElementsById("Antwoord1b");
let Answers_Students = [Antwoord1a, Antwoord1b]
let Correct_Answers = ["SELECT title FROM movies;", "SELECT director FROM movies;"]
var Score_Student = 0
for (var i = 0; i < Answers_Students.length; i++) {
if (Answers_Students[i] === Correct_Answers[i]) {
Score_Student += 1;
} else {
}
}
Upvotes: 0
Views: 108
Reputation: 896
document.getElementById()
returns the DOM element. To get the value of that element you need .value
property:
const Student_Answers_1a = document.getElementsById("Antwoord1a").value;
Upvotes: 1