dropdown in php not retaining value ...
Hello;
I am trying to get an html dropdown box to work and it kind of does. The box works okay, but the information does not retain itself. Basically I have some code that checks some basic criteria for fields. The form calls itself so that the column next to the field displays an error message if something is wrong. If something is wrong on say the first name, the state jumps back to
"None" instead of displaying the actual value ( although it retains the value ). I could send entire code, but I think this gives the idea.
// State must be 2 characters
if(preg_match("/^[A-Z_]{2,}$/", $_POST["state"]) === 0)
$errState = '<class="errText">State can not be None';
************************************************** ********
<tr>
<td width="124" bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#3366FF"> State:</font></b></td>
<td width="278"> <select size="1" name="state">
<option selected>None</option>
<option value="WA">Washington</option>
<option value="CA">California</option>
<option value="BC">British Columbia</option>
<option value="AB">Alberta</option>
</select></td>
<td> <?php if(isset($errState)) echo $errState; ?></td>
</tr>
************************************************** ********
//This will check if data is retained for state. Last Name has to have information for this to display !!!
// Last Name must be letters, dash and spaces only
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["lname"]) === 0)
$errLName = '<class="errText">Last name must be from letters, dashes, spaces and must not start with dash';
else
$errStatus = $_POST["state"];
|