In Empire CMS, when performing a search, the form name can only be set to "keyboard"; therefore, when conducting a multi-condition search with multiple search fields, the single-select field may encounter issues. As a result, alternative approaches must be adopted to handle this situation.
HTML code:
<label class="area-box-listhover">
<input class="inputcheckbox" type="checkbox" name="address[]" value="上海">
<span class="area-box-name">上海</span>
</label>
<label class="area-box-listhover">
<input class="inputcheckbox" type="checkbox" name="address[]" value="山东">
<span class="area-box-name">山东</span>
</label>
<label class="area-box-listhover">
<input class="inputcheckbox" type="checkbox" name="address[]" value="四川">
<span class="area-box-name">四川</span>
</label>jQuery code:
$(document).ready(function() {
// 获取所有需要控制的盒子
var boxes = $('#box3');
// 遍历每个盒子
boxes.each(function() {
// 获取盒子内的 checkbox input
var checkboxes = $(this).find('input[type="checkbox"]');
// 绑定 checkbox 的 change 事件
checkboxes.change(function() {
// 取消其他盒子的选中状态
boxes.not(this).find('input[type="checkbox"]').prop('checked', false);
// 取消本盒子的其他选中状态
$(this).prop('checked', true);
});
});
});This allows you to restrict the multiple-selection input field within a specified container to a single-selection mode, thereby achieving better search performance.