Chezshire Posted May 7, 2009 Share Posted May 7, 2009 I think i've isolated my problem to the select, but I can't figure out how to resolve it unfortunately. What is suppose to happen is that when the form is selected, the selection should submit, however when the form is submited, the selection defaults to '---undecided---' instead. Help? Here is my code: <p><select name="FCREQUESTLDB" size="1"> <option value="">---- Undecided ----</option> <!-- Comment --> <?php // --- Begin Select FCs Only //<p><textarea name="FCREQUESTLDB" cols="45" rows="20"> //<?php echo htmlspecialchars($player["fcRequestLDB"]); // Goal - only list approved, available characters - not deceased, npcs, etc. $result=mysql_query("SELECT * FROM cerebra WHERE approved != 'inactive' AND ocfcDB = 'FC' AND player = 0 AND npc='' ORDER BY codename", $db); // let's pull a list of already-requested chars $reqList = array(); $reqResult = mysql_query("SELECT fcRequestLDB from login GROUP BY fcRequestLDB"); WHILE ($row = mysql_fetch_assoc($reqResult)) { $reqList[] = $row["fcRequestLDB"]; } $currentType=""; WHILE ($myChar = mysql_fetch_array($result)) { // we only show an option if this char id is NOT found in the list of already-requested chars if (!array_search($myChar["id"], $reqList)) { // set the value of this option $entryName = strtoupper($myChar["codename"]) . " (" . $myChar["name"] . ")"; // output the HTML for the option echo '<option value="'. $myChar["id"] . '"'; // should it be selected? if ($myChar["id"] == $player["fcRequestLDB"]) {echo " selected"; } echo '>' . strtoupper($myChar["codename"]); if ($myChar["name"]) { echo " (" . $myChar["name"] . ")"; } echo "</option>\n"; } // end IF NOT IN REQ ARRAY } // END WHILE // --- End Select Available FCs Only ?></select> </p></td></tr> Any help is appreciated Link to comment https://forums.phpfreaks.com/topic/157193-my-select-wont-stay-selected/ Share on other sites More sharing options...
vinothini Posted May 7, 2009 Share Posted May 7, 2009 when u do selection get the value of that and assign the same value to the dropdown using javascript.... orelse using php check the selected value is matching with the value in the list selected=selected....so it ll stay in the selection... hope u understood.... Link to comment https://forums.phpfreaks.com/topic/157193-my-select-wont-stay-selected/#findComment-828288 Share on other sites More sharing options...
Chezshire Posted May 7, 2009 Author Share Posted May 7, 2009 Thank you for the explanation Vinothini, Unfortunately I don't know Java I am reading a book on it right now but intermingling it with PHP would be beyond me at this time (I'm very new to this all really - I barely understand CSS I think sometimes). Thank you for pointing me to the selected=selected, I will try to see if I can figure it out from that. If anyone else has pointers please feel free to pass them on, it'd be greatly appreciated. Thank you. Link to comment https://forums.phpfreaks.com/topic/157193-my-select-wont-stay-selected/#findComment-828610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.