Home > database >  Select2 Dropdown options disappear once I select any option
Select2 Dropdown options disappear once I select any option

Time:04-08

<select rows='3' name="user_id[]" required="required" multiple  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.

CodePudding user response:

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

CodePudding user response:

$(".select2").select2({
    closeOnSelect: false
});

Just add this and it will work

  • Related