[Solved] disable dropdown list if not contain any value using php


Try this script:

<?php
  $aFilters['AgentName'];


    $i = 0;

  foreach($agentsName as $ar) {
    echo "<option value="$ar->id">$ar->first_name$ar->last_name</option>";
    $i++;
  }
  ?>
<select <?php if ($i > 0) { echo " disabled "} ?> name="AgentName" id='selAgentName'>
<option value="">Select Agent</option>
</select>

remove drop down script:

<?php 
$aFilters['AgentName'];
$i = 0;

foreach($agentsName as $ar) { 
    $i++; 
    if ($i>1) { 
        echo "<select name="AgentName" id='selAgentName'>";
        echo "<option value="$ar->id">$ar->first_name$ar->last_name</option>"; 
    } 
} 
?>
<option value="">Select Agent</option>
</select>

EDIT: Fixed all bugs

5

solved disable dropdown list if not contain any value using php