Jump to content

How do you collect string data into combo boxes(form)! [SOLVED]


ted_chou12

Recommended Posts

Sorry for posting lots of new topics, but i really need helps with these.
So far, ive learnt how to input information information easily into textarea and input boxes, eg. <?php echo"$string"?>, however im having trouble inputing the to the combo boxes, (ie. the selection types)
is there any easy way to do that?
Thanks :D
Edited: nope, i think you got the wrong picture here, what i wish to do is having the combo box selecting the value that I previously submitted, not collecting the value selected, if you still dont understand my point i will explain it in further details
thanks for understanding.

i dont quite understand, could you explain please?
eg.
[code]
<tr><td valign=top><font face="Arial">Background Color:</font></td>
<td><select name="bgcolor" size="1">
<option value="FFFFFF">White</option><option value="87CEFA">Light sky blue</option><option value="FFA500">Orange</option><option value="8B4513">Saddle brown </option><option value="C0C0C0">Silver</option><option value="FA8072">Salmon</option><option value="CD853F">Peru</option><option value="D2B48C">Tan</option><option value="FF69B4">Hot pink</option></select></td></tr>
[/code]

these are my multiple choices, where would i have to put the $_GET['bgcolor']?
thanks a lot by the way
The easiest way I've found:

[code]$colors = array(
'FFFFFF' => 'White',
'87CEFA' => 'Light sky blue',
'FFA500' => 'Orange',
'8B4513' => 'Saddle brown ',
'C0C0C0' => 'Silver',
'FA8072' => 'Salmon',
'CD853F' => 'Peru',
'D2B48C' => 'Tan',
'FF69B4' => 'Hot pink'
);

$color_select = "";

foreach ($colors as $hex => $color) {
$color_select .= '
<option value="' . $hex . '"';

if ($hex == $_POST['bgcolor']) {
$color_select .= ' selected';
}

$color_select .= '>' . $color . '</option>';
}

?>
<tr>
<td valign=top><font face="Arial">Background Color:</font></td>
<td>
<select name="bgcolor" size="1">
<?php echo $color_select; ?>
</select>
</td>
</tr>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.