Page is a not externally linkable
rocknbil - 5:50 pm on Oct 28, 2011 (gmt 0)
To get one thing out of the way: are you using an XHTML doctype or HTML/HTML5?
For HTML, it's
<option value="some-value" selected>
for XHTML, it's
<option value="some-value" selected="selected">
i want after the drop down choosed by user, it will add SELECTED next time they opening the drop down again
You **should** have these select lists generated by a function, but this simple example assumes this form is using POST as a method. I don't use form arrays often, doesn't look like you need them, so to avoid "incorrect code" I'm using a static name. Change the names as needed . . .
$using_xhtml = 0; // because most of us don't need to . .
$selected_syntax=($using_xhtml==1)?' selected="selected"':' selected'; }
$vals = array ('1','2','3','4');
$this_select = '
<select class="input" name="cpu">
<option value=""> </option>
';
foreach ($vals as $val) {
$this_select .= '<option value="' . $val . '"';
if (isset($_POST['cpu']) and ($_POST['cpu']==$val)) { $this_select .= $selected_syntax; }
$this_select .= '>' . $val . '</option>';
}
$this_select .= '</select>';
echo $this_select;
I'd also advise against using selectors that may conflict with the dom, such as input, search, select, display, etc . . . it gets very confusing
.input input {}