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

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -