0

Hi guys, i have a drop down code below


<select class="input" name="mod[cpu]">
<option value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

the output are like this

$html .= ($content[cpu] ? '<div class="' . $this->switch_bg() . '"><strong>CPU:</strong> ' . @htmlspecialchars($content[cpu]) . '</div>' : '');

i want after the drop down choosed by user, it will add SELECTED next time they opening the drop down again

i am still dont know how to put the SELECTED there, please help what is the code to add SELECTED, i only have variable mod[cpu] and $content[cpu]


i already tried in bold below, but still not working

<select class="input" name="mod[cpu]" selected="$content[cpu]">
<option value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

please share your knowledge

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by adumpaul
0

I think you need to save users' choice in the database. And when you show it, you make the PHP or whatever you use read the data from database. If the value of the option is equal to the value in database, then

<option value="xxx" selected="selected">xxx</option>

.
Otherwise, just write

<option value="xxx"></option>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.