一旦我选择任何选项,Select2 下拉选项就会消失

发布于 2025-01-20 00:42:35 字数 1181 浏览 0 评论 0原文

<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'
});

我在Select2 jQuery中有一个学生下拉菜单,但假设我单击了它被选中的任何一个名称,但选项消失了。我必须再次单击以查看学生列表,然后再次单击任何其他名称。我只想一次选择多个。

<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'
});

enter image description here

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟酒忠诚 2025-01-27 00:42:35
$(".select2").select2({
    placeholder: "Select here",
    width: 'resolve',
    closeOnSelect: false
});

关闭选择: false
通过使用这个属性,我实际上得到了我想要的东西。我已将其设置为 false,这样它就不会在选择任何一个选项时关闭。

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

closeOnSelect: false
by using this property I have actually got what I was looking for. I have set it to false so that it doesn't get closed on selection of any one of the options.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文