Simple example using PHP to select the current option.
HTML Code:
<?php
$options = array('output'=>array('one','two','three','four'),'values'=>array(1,2,3,4));
$selected = isset($_POST['select']) && in_array($_POST['select'],$options['values'])?$_POST['select']:null;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Untitled</title>
</head>
<body>
<?php echo $selected!==null?'<p><strong>Current Option</strong> '.$selected.'</p>':''; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<fieldset>
<legend>Example</legend>
<select name="select">
<option value="0">--</option>
<?php
foreach($options['values'] as $index=>$option) {
echo '<option value="'.$option.'"'.($selected !== null && $selected == $option?' selected="selected"':'').'>'.$options['output'][$index].'</option>';
}
?>
</select>
<input type="submit" name="save" value="Submit">
</fieldset>
</form>
</body>
</html>
Bookmarks