简体   繁体   English

Select2 下拉选项消失一次我 select 任何选项

[英]Select2 Dropdown options disappear once I select any option

<select rows='3' name="user_id[]" required="required" multiple class="form-control select2" style="width: 100% !important">
    <?php
    $qid = $_GET['id'];
    $student = $conn->query('SELECT u.*,s.course as ls, s.branch, s.year FROM users u left join students s on u.id = s.user_id where u.user_type = 3 ');
    while ($row = $student->fetch_assoc()) {
        $user_id = $row['id'];
        $result = $conn->query('SELECT * FROM quiz_student_list where quiz_id ="'.$qid.'" and user_id = "'.$user_id.'"');
        if ($result->num_rows == 0) {
        ?>  
        <option value="<?php echo $row['id'] ?>"><?php echo ucwords($row['name']) . ' ' . $row['ls'] . ' ' . $row['branch'] . ' ' . $row['year'] ?></option>
    <?php } 
    }
    ?>
</select>



$(".select2").select2({
    placeholder: "Select here",
    width: 'resolve'
});

在此处输入图像描述

I have a students dropdown in select2 jquery but suppose I click on any one of the name it got selected but the options disappears.我在 select2 jquery 中有一个学生下拉菜单,但假设我单击了它被选中的任何一个名称,但选项消失了。 I have to click again to see the students list and click again on any other name.我必须再次单击以查看学生列表,然后再次单击任何其他名称。 I want to select multiple in one go only.我只想 select 多合一 go。

$(".select2").select2({
    placeholder: "Select here",
    width: 'resolve',
    closeOnSelect: false
});

closeOnSelect: false by using this property I have actually got what I was looking for. closeOnSelect: false 通过使用这个属性,我实际上得到了我想要的东西。 I have set it to false so that it doesn't get closed on selection of any one of the options.我已将其设置为 false,这样它就不会在选择任何一个选项时关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM