ted_chou12 Posted December 9, 2006 Share Posted December 9, 2006 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 Quote Link to comment Share on other sites More sharing options...
fert Posted December 9, 2006 Share Posted December 9, 2006 [code]<select name="name"<option value="value1">value1</option><option value="value2">value2</option></select>[/code]then $_POST['name'] or $_GET['name'] will have the value that was selected. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 9, 2006 Author Share Posted December 9, 2006 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 detailsthanks 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 Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 9, 2006 Share Posted December 9, 2006 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] Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 9, 2006 Author Share Posted December 9, 2006 thanks so much so much, you saved my life! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.