2016-09-21 3 views
0

Ich habe ein Land Dropdownaktualisieren Dropdown Wert

<select name="country" class="form-control"/> 
    <option>Select a Country</option> 
    <?php foreach($country_list as $country) :?> 

     <option value="<?php echo $account_result->Country;?>" 
     <?php 
     if($country->id==$account_result->Country) 
     {echo 'selected="selected"';};?>> 
     <?php echo $country->name; ?></option> 
    <?php endforeach; ?> 
</select> 

aber während der Aktualisierung ich nur ausgewählte Wert id immer ändert es nicht.

Antwort

0

Sie denselben Wert für alle Optionen Einstellung ändern, um diese Zeile: <option value="<?php echo $account_result->Country;?>" zu: <option value="<?php echo $country->id;?>"

0

Versuchen unter

Sie haben

<select name="country" class="form-control"/> 
    <option>Select a Country</option> 
     <?php foreach($country_list as $country) :?> 

      <option value="<?php echo $country->id;?>" 
      <?php 
      if($country->id==$account_result->Country) 
      {echo 'selected="selected"';};?>> 
      <?php echo $country->name; ?></option> 
     <?php endforeach; ?> 
</select> 
in Option falsch Wert
0
<?php echo $country->id == $account_result->Country ?"selected":"";?> 

Ihre $country->id und $account_result->Country sh Ould gleichen Wert Beispiel sein

ex: 44 = 44

dann wird es in Standardseite Last ausgewählt erhalten werden.

und Sie müssen den Wert der Option wie folgt setzen.

<option value="<?php echo $country->id;?>" 
Verwandte Themen