PCHomepage
Programmer
This dynamic listbox is working fine except for the SELECTED which is always for the first item no matter what is selected and it's likely to do with the fact that the select has an on submit function. The Onsubmit function is required so is there a workaround for the SELECTED?
Code:
<select name="FormName" onchange="this.form.submit()">
<?php
if ($result = $mysqli->query($LevelQuery1)) {
$i = 1;
while ($row = $result->fetch_row()) {
if ($i = 0) {
$value = "SELECTED value=\"" . $row[0] . "\"";
} else {
$value = "value=\"" . $row[0] . "\"";
}
$selectBox_g_a0 .= "<option " . $value . ">" . $row[0] . "</option>\n";
$i++;
}
$result->close();
}
echo $selectBox_g_a0;
?>
</select>