I am trying to select for 2 attributes that are variable on a multiple choice quiz. I echoed the correct answer to each question in an input
that doesn't display on the page. I think my line where I select for 2 different attributes is the problem.
JQUERY:
var zz = 1;
while (zz <= <?php echo $num_rows ?>){ //I'm 100% postive $num_rows returns a value of 3
var zstring = '#answer' + zz;
var theanswer = $(zstring).attr('value'); //should return "a" or "c" or whatever the answer is
if $("input[name=zz][value=theanswer]").is(':checked') { //this is the line that's not working
alert("the code worked");
}
zz++;
}
HTML echoed from PHP
echo "<input type='radio' name=" . $question_number ." value='a'> A. " . $chA . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='b'> B. " . $chB . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='c'> C. " . $chC . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='d'> D. " . $chD . "<br><br>";
echo "<input type='radio' name=" . $question_number ." value='e'> E. " . $chE . "<br>";
echo "<input type='text' id='answer".$question_number."' style='display: none;' value='".$correct."' />";
I see that in the if statement you have this:
it should be: