У меня есть рабочий код для проверки флажков , но он работает только в том случае, если первый флажок уже установлен. Ребята, может быть, у вас есть идея, почему?Флажки Auto check на основе поля выбора
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 (безопасно, потому что он будет реализован в 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);
}
}
@Tushar Нет, это действительно первая проблема, последняя я могу исправить :) –