我需要使用php中的codeigniter框架将select2值显示在我的下拉列表框中。 对于前: 1)博士。 Abhay Nene 2)博士。 Ajoy Shetty
我已经选择了这个名字。它显示在列表中。但它没有在列表中显示为选中。
<select class="multiple-select2 form-control" name="reviwerid[]" multiple="multiple" id="userRequest_activity" required>
<?php
$cats = explode(',', $res->abstract_reviewerid);
print_r($cats);
echo $count_no = count($cats);
foreach($cats as $vald)
{
foreach($reviewresults as $reviewresult)
{
if($reviewresult->reviewer_name != "")
{ ?>
<option <?php ($vald == $reviewresult->reviewer_id) ? 'selected=' : '') ?> value="<?php echo $reviewresult->reviewer_id; ?>">
<?php echo $reviewresult->reviewer_name; ?></option>
<?php }
}
} ?>
</select>
please help me how to do this?
thanks in advance...!
[1]: https://i.s
这是我的PHP代码: tack.imgur.com/0K31f.jpg
答案 0 :(得分:0)
试试这个:
<link rel='stylesheet' type='text/css' href='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css' />
<select multiple id="e1" style="width:400px">
<option value="1">Dr. Abhay Nene</option>
<option value="2">Dr. Ajoy Shetty</option>
</select>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.full.min.js"></script>
<script type="text/javascript">
$("#e1").select2();
</script>