gpt4 book ai didi

javascript - jquery ui 多选不适用于多选+单选

转载 作者:行者123 更新时间:2023-11-28 09:52:12 31 4
gpt4 key购买 nike

我正在使用这个插件http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#single对于多选,并且希望也可以在同一页面中进行单选。基本上我有两个选择 - 一个是多个,另一个是单个,但我想将它们设置为相同的样式。所以我尝试:

<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>

问题是多选有效,但单选根本不起作用(我无法选择任何内容,列表被下拉,但没有选择任何内容)。知道为什么吗?非常感谢。

最佳答案

altceva should be the id of multiselect dropdown and ceva should be the id of single dropdown.... Go for the below code...:)

<script type="text/javascript">
$(window).load(function(){
$("#altceva").multiselect({
multiple: true,
header: false,
noneSelectedText: "Select an Option",
selectedList: 1
});

$("#ceva").multiselect({
multiple: false,
header: false,
noneSelectedText: "Select an Option",
selectedList: 1
});
});
</script>

关于javascript - jquery ui 多选不适用于多选+单选,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10765268/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com