Hi all, I want to display a particular number as selected in the dropdown list only if it is equal to $package->quantity I am having the following code but in the below code i'm having a problem.That problem is the particular number from that list is missing instead of selecting displaying as selected what may be the problem here can any body find it? the have gone through out the code 100 times but cant trace the mistake here.... the code is... <select> <?php for($i=1;$i<=10;$i++){ echo "<option"; if($i == $package->quantity) { echo "Selected='selected'"; } echo ">"; print $i; echo "</option>"; } ?> </select> Thanks in advance...
would it be a problem here? I dont think so... If yes means can you explain the reason? Any way i'll try it and reply you...
Add a space before "Selected". Probably not showing up because that particular option gets formatted as "<optionSelected='selected'>$i</option>". echo " Selected='selected'"; PHP: