Checkbox not showing as checked
The issue is I have a page with the following checboxes listed for a particular question.When I select one of the boxes and go to the next page and comeback then i find,none of the checkboxes appear to be checked.I have checked it on the back end and i was able to see that the checkboxes were indeed checked,but i was not able to view them as checked.I am not able to figure out as to why they don开发者_StackOverflow中文版t appear to be checked.Any help regarding this would be appreciated.Thanks in Advance. The following is the code which i have in that page.
<td>
<input type="checkbox" name="test_na" value="N/A" <?=$test_na?> id="test_na">
<label for="test_na">NA</label>
</td>
<td>
<input type="checkbox" name="test_y" value="Y" <?=$test_y?> id="test_y">
<label for="test_y">Yes</label>
</td>
<td>
<input type="checkbox" name="test_n" value="N" <?=$test_n?> id="test_n">
<label for="test_n">No</label>
</td>
Test the value of the checkoxes and echo checked
if value matches.
<td>
<input type="checkbox" name="test_na" value="N/A" <?php echo (isset($test_na) && $test_na == 'N/A' ? 'checked' : ''); ?> id="test_na">
<label for="test_na">NA</label>
</td>
<td>
<input type="checkbox" name="test_y" value="Y" <?php echo (isset($test_y) && $test_y == 'Y' ? 'checked' : ''); ?> id="test_y">
<label for="test_y">Yes</label>
</td>
<td>
<input type="checkbox" name="test_n" value="N" <?php echo (isset($test_n) && $test_n == 'N' ? 'checked' : ''); ?> id="test_n">
<label for="test_n">No</label>
</td>
See page source. What in your variables? It should be checked="checked"
or checked="yes"
or checked="1"
精彩评论