PHP drop down return to previous selection

VovaZekradsivs

New Member
Ok this is a very small section of my original code. I have two pages a page full of forms and boxes then another page that puts the information into my DB. Oasis.php pageThis right here is the code that changes the client name and code. On this entire page. On the change event.\[code\]$sql = "SELECT * FROM client_lookup ORDER BY Client_Full_Name ASC"; $result = mysql_db_query ($dbName, $sql, $dbLink); $options4=""; while ($row = mysql_fetch_array($result)) { $id=$row["Client_Code"]; $thing=$row["Client_Full_Name"]; $options4.="<OPTION VALUE=http://stackoverflow.com/questions/2096758//"$id, $thing\">".$thing; } ?><FORM name="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"><SELECT NAME="ClientNamefour" OnChange="this.form.submit()"> <OPTION VALUE=http://stackoverflow.com/questions/2096758/0>Client <?php echo $options4?> </SELECT></FORM>\[/code\]Once the form below this on the Oasis.php page is submitted it goes to the process page and puts the information into my data base. Once that is done I have a header that returns me to this page. But as default the Client is always returned. In an attempt to return the previously selected client from this drop down I used this code. To automatically select the last selected client.\[code\]$sql = "SELECT * FROM client_lookup ORDER BY Client_Full_Name ASC"; $result = mysql_db_query ($dbName, $sql, $dbLink); session_start();$current = isset($_SESSION['ClientNamefour']) ? $_SESSION['ClientNamefour'] : 0;$options4=""; while ($row = mysql_fetch_array($result)) { $id = $row["Client_Code"]; $value = http://stackoverflow.com/questions/2096758/$row["Client_Full_Name"]; $key = "$id, $value"; $selected = ($id == @$_SESSION['ClientNamefour']) ? ' selected' : ''; $options4.="<option value=http://stackoverflow.com/questions/2096758//"{$key}\"{$selected}>{$value}";} ?><FORM name="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"><SELECT NAME="ClientNamefour" OnChange="this.form.submit()"> <OPTION VALUE=http://stackoverflow.com/questions/2096758/0>Client <?php echo $options4?> </SELECT></FORM>\[/code\]This works but the onchange event doesn't not work! So it doesn't Post itself. The on change event is key or my whole page doesn't populate with information.
 
Back
Top