I have working code to check checkboxes but it only works if the first checkbox is already checked. Do you guys maybe have any idea why?
HTML:
<p id="ullman_seats"><input class="choice" type="checkbox" name="option['option']" value="3000"> Ullman seats
<select id="select_ullman">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</p>
<p id="ullman_seats_2"><input class="choice" type="checkbox" name="option['option']" value="3000"> Ullman seats</p>
<p id="ullman_seats_3"><input class="choice" type="checkbox" name="option['option']" value="3000"> Ullman seats</p>
<p id="ullman_seats_4"><input class="choice" type="checkbox" name="option['option']" value="3000"> Ullman seats</p>
jQuery (safe because it will be implemented in WordPress)
jQuery('#select_ullman').change(function () {
if (jQuery(this).val() == '2') {
jQuery('#ullman_seats input').attr('checked', true);
jQuery('#ullman_seats_2 input').attr('checked', true);
}if (jQuery(this).val() == '3') {
jQuery('#ullman_seats input').attr('checked', true);
jQuery('#ullman_seats_2 input').attr('checked', true);
jQuery('#ullman_seats_3 input').attr('checked', true);
}if (jQuery(this).val() == '4') {
jQuery('#ullman_seats input').attr('checked', true);
jQuery('#ullman_seats_2 input').attr('checked', true);
jQuery('#ullman_seats_3 input').attr('checked', true);
jQuery('#ullman_seats_4 input').attr('checked', true);
}
}
Aucun commentaire:
Enregistrer un commentaire