So I have the following code:
// the loop
$countId = 0;
$dateOnce = '';
foreach ($postDates as $post):
if (substr($post->post_date, 0, 7) != $dateOnce) {
echo'
<div class="checkbox">
<label for="filterByPostDate-' . $countId . '">
<input type="checkbox" id="filterByPostDate-' . substr($post->post_date, 0, 7) . '" class="postDateFilters postDateFilterCb-' . $countId . '" name="filterByPostDate-' . $countId . '" value="' . substr($post->post_date, 0, 7) . '" '; if (isset($_SESSION["filterByPostDate"])) { $key = array_search(substr($post->post_date, 0, 7), $_SESSION["filterByPostDate"]); } else { $key = false; } if($key !== false) { echo 'checked'; } echo ' />
' . date('M, Y', strtotime($post->date_part)) . '
</label>
</div>
';
}
$dateOnce = substr($post->post_date, 0, 7);
$countId++;
endforeach;
// END the loop
Which outputs checkboxes and labels for the wordpress frontend. But when I click on the label for each checkbox the checkbox doesn't get selected.
Here is a js fiddle which shows the problem.
Cheers for the help.
Aucun commentaire:
Enregistrer un commentaire