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

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -