我正在使用这个插件http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#single进行多选,也希望在同一页面中进行单选。基本上我有 2 个选择 - 一个是多个,另一个是单个,但我想将它们设置为相同的样式。所以我尝试:
<script type="text/javascript">
$(function(){
$("#altceva").multiselect({
multiple: false,
header: "Select an option",
noneSelectedText: "Select an Option",
selectedList: 1
});
$("#ceva").multiselect();
});
</script>
和选择:
<select name="123_cat[]" id = "ceva" multiple="multiple" size="5">
<?php foreach($subcategories['categories'] as $sc) { ?>
<optgroup label="<?php echo $sc['name']; ?>">
<?php foreach ($sc['subcategories'] as $ss){?>
<option id = "123_cat" value="<?php echo $ss['sid']; ?>" <?php if (isset($_GET['123_cat'])) { if(in_array($ss['sid'], $_GET['123_cat'])) echo "selected = 'selected'";} else { if(in_array($ss['sid'], $the_subcategories)) echo "selected = 'selected'"; } ?>><?php echo $ss['name']; ?></option>
<?php }?>
<label for="oras">Oras</label>
<select name="123_city" id = "altceva">
<?php foreach($ac as $rc) {?>
<option id = "123_city" value="<?php echo $rc['slug']; ?>" <?php if (isset($_GET['123_city'])) { if ($rc['slug'] == $_GET['123_city']) echo 'selected = "selected"';} else { if ($rc['slug'] == $my_data->city) echo 'selected = "selected"';} ?>> <?php echo $rc['name']; ?> </option>
<?php } ?>
</select>
问题是多选有效,但单选根本不起作用(我无法选择任何内容,列表被下拉,但没有选择任何内容)。知道为什么吗?多谢。