I'm trying to make a trivia game thing, it'll have nice CSS layouts later. But I need to write the result on the page (easy) but I can't think of a good way to process the result. Here's my code:
function testResults (form) {
var answer = form.inputbox.value;
if (answer == /*This is where I'm having troubles at! */) {
document.getElementById("result").innerHTML = "Right!"
} else {
document.getElementById("result").innerHTML = "Wrong!"
}
var triviaQ = [];
triviaQ[0] = {que: "Answer true.", ans: true}
triviaQ[1] = {que: "Answer false.", ans: false}
triviaQ[2] = {que: "Answer John.", ans: "John"}
triviaQ[3] = {que: "Answer herp.", ans: "herp"}
var Q = triviaQ.length;
var currentTrivia=Math.round(Math.random()*(Q-1));
function showtriviaQ(){document.getElementById("question").innerHTML = triviaQ[currentTrivia];}
As you can see, I have most of it complete except for where the comment is. The "if" statement starts with a check of YOUR answer (from a text box) to the current question's property.
The questions are completely random as a test to see if it would work, but I can't figure out a way to write the properties in the "if" statement check.