Reputation: 21
i am a beginner in coding. i have this kind of code.
<div class="row_add_house">
<span><?php echo _REALESTATE_MANAGER_LABEL_LISTING_TYPE; ?>:</span>
<span><?php echo $listing_type_list; ?></span>
</div>
At front end, this will appear as a drop down selection, and the $listing_type_list appear with three selection:
and the 'select' is set by default. how can i set 'house for rent' as a default selection? anyone please help me.
if ($house->listing_type != 1) {
?>
<tr>
<td class="first_td" align="right">
<strong><?php echo _REALESTATE_MANAGER_LABEL_LISTING_TYPE; ?>:</strong>
</td>
<td width="270px" align="left">
<?php
$listing_type[0] = _REALESTATE_MANAGER_OPTION_SELECT;
$listing_type[1] = _REALESTATE_MANAGER_OPTION_FOR_RENT;
$listing_type[2] = _REALESTATE_MANAGER_OPTION_FOR_SALE;
echo $listing_type[$house->listing_type];
?>
</td>
</tr>
<?php
this is another part of the coding. this seems to be the 'if' statement of the dropdown menu, if the option is selected to 'for rent'of the dropdown menu. there are the option for $listing_type_list. how can i set the option automatically to select the $listing_type[1]?
Upvotes: 2
Views: 104
Reputation: 37
It would be more clear if you can provide value of $listing_type_list.
Anyway, to make any option of drop down as default selected, you have to write 'selected' property as below:
<option selected="selected">
Hope it will resolve your query.
Upvotes: 1