How can you make this working?
<? print(" <center><form action='$PHP_SELF' method='POST'>
<select name='selected'>
<option value='100'>100</option>
<option value='200' selected>200</option>
<option value='300'>300</option>
<option value='400'>400</option>
<option value='500'>500</option>
<option value='600'>600</option>
<option value='700'>700</option>
<option value='800'>800</option>
<option value='900'>900</option>
<option value='1000'>1000</option>
</select><input type='submit' value='Selected Option'>
</form></center>");
function make_options($options, $selected) {
// I didn't know how to include it
global $option;
while (list($key, $val) = each($option)) {
if (array_intersect(array($val), $selected)) {
echo "<OPTION VALUE='$val' SELECTED>$val\n";
} else {
echo "<OPTION VALUE='$val'>$val\n";
}
}
}
$option = array('100','200','300','400','500','600','700','800','900','1000');
// Somethings wrong here I must be tired
make_options($option,$selected);
?>
Can you show us how?Please. Tx.
Majik Sheff wrote:
This function will generate all of the <OPTION> tags that go inside of your <SELECT NAME='x' MULTIPLE> Tag:
Just feed this function an array of all of your options and an array of your selected options.
function make_options($options, $selected) {
while (list($key, $val) = each($options)) {
if (array_intersect(array($val), $selected)) {
echo "<OPTION VALUE='$val' SELECTED>$val\n";
} else {
echo "<OPTION VALUE='$val'>$val\n";
}
}
}