php - echo selected in chosen select -
i using chosen select drop down show auto complete drop down. want set selected value edit. tried following code works normal select option not working chosen select
<select class="chosen-select" > <option value=""></option> <?php if(!empty($list)) { foreach($list $d) { ?> <option value="<?php echo $d->id; ?><?php if($d->id == 2) { echo "selected"; } ?>"><?php echo $d->name; ?></option> <?php } } ?> </select>
you putting selected
inside value
attribute, need write after :
<select class="chosen-select" > <option value=""></option> <?php if(!empty($list)) { foreach($list $d) { ?> <option value="<?php echo $d->id; ?>"<?php if($d->id == 2) { echo " selected"; } ?>><?php echo $d->name; ?></option> <?php } } ?> </select>
Comments
Post a Comment