I am building a self scoring quiz that displays each question with the answer chosen by the user and a mark of right or wrong.
The values are declared in the form (quiz) that are passed to the score sheet eg:
<input onclick=”A0=’a’;A0a=’Aardvark'” type=”radio” name=”R1″ />
<input onclick=”A0=’b’;A0b=’Bat'” type=”radio” name=”R1″ />
<input onclick=”A0=’c’;A0c=’Cat'” type=”radio” name=”R1″ />
<input onclick=”A0=’d’;A0d=’Dog'” type=”radio” name=”R1″ />
Then when the user is done and clicks the check button the score sheet adds the correct answers by adding with an If statement that compares just the correct answer letter (a, b, c, or d) then adds just the correct ones using i=i+1.
Then use a document.write to write the question and the answer chosen to the score sheet to be viewed. Calling the answer letter with A0 is easy enough but I’m trying to call the values of A0a, A0b, A0c, A0d by concatenate the variable name for the answer text with this:
Answers.document.write(“+(“A0″+(A0.toLowerCase()))+”);
This outputs the right name of the variable name if the “a” radio button is clicked then the output shows “A0a” but I can’t get the value of A0a = “Aardvark” to be written to the score sheet.