一旦我选择任何选项,Select2 下拉选项就会消失
<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'
});
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关闭选择: false
通过使用这个属性,我实际上得到了我想要的东西。我已将其设置为 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.