Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

$(".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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!