Jump to content

My Select won't stay selected


Chezshire

Recommended Posts

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

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.

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.