How come this returns an error?
In my head tag…
var movieArray = [
["Everything is Illuminated", "0", ""],
["The Girl Who Leapt Through Time (Toki wo kakeru shojo)", "1", "<ol><li><span class=\"bold quote_actor\">Kosuke Yoshiyama: </span><span class=\"line\">It's not that rare. Many girls do it at your age.</span></li> </ol>"],
["Freedom Writers", "0", ""],
["Inside Man", "0", ""]
];
function checkAnswer(this.value) {
if (this.value == 0) {
alert ("Wrong answer!");
} else {
alert ("Correct Answer!");
}
}
In the body…
<p><a id="0" class="btn btn-primary btn-large" value="0" onclick="checkAnswer(this.value)">Everything is Illuminated</a></p>
<p><a id="1" class="btn btn-primary btn-large" value="1" onclick="checkAnswer(this.value)">The Girl Who Leapt Through Time (Toki wo kakeru shojo)</a></p>
The error is checkAnswer() is not defined. How come?
Thanks.
You forgot to escape
"inside array elements by adding backslashSecondly
this.valueshould be passed while calling the checkAnswer() and not at the time of defitinion