assign dynamically selected to option by select2
I try to add selected dynamically to select2 via php on returned get
variable but I can't figure out how to do this. I was trying the following
but I suppose this needs to be done with jquery
<select id="grade" name="grade" style="width:125px">
<?php foreach ($abs as $index => $a): ?>
<?php '<span class="select2-chosen">'.$a.'</span>' ? $grade ==
strtolower($index) : '' ?>
<option value="<?php echo $index ?>"
><?php echo $a ?></option>
<?php endforeach; ?>
</select>
No comments:
Post a Comment