[eluser]Khoa[/eluser]
Hi,
I have a view that contains a form, inside that form I have a dropdown box that contains the list of countries as follows:
Code:
// inside the form.php controller
$data['countries'] = "SOME QUERY TO GET THE LIST OF COUNTRIES IN RESULT_ARRAY";
$this->parser->parse('form', $data);
// inside the form.php view
<select>
{countries}
<option value="{id"}>{name}</option>
{/countries}
</select>
How can I make Australia, which has the country id of 13 in this case, to be selected by default?
I tried the followings but they don't work:
Code:
// This does not work
<select>
{countries}
<option value="{id"} <?php if($id == 13) echo "selected"; ?>>{name}</option>
{/countries}
</select>
// nor does this
<select>
{countries}
<option value="{id"} <?php if("{id}" == 13) echo "selected"; ?>>{name}</option>
{/countries}
</select>
Any idea how to do this?
Thanks