Page 1 of 1

retaining previously entered values in list/menu box

Posted: Fri May 09, 2003 3:08 am
by jarow
I have a user registration form that gives error responses if the info isn´t entered correctly. An error response will cause the output form to appear again with the previously entered values. How do I get a list/menu to display the previously entered value?


Following is a couple of lines from the script that explain what I mean.

Code: Select all

<?php
echo '<tr><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Contrasena:</td><td><input name="password" type="password" id="password" value="'.htmlspecialchars($_POST['password']).'"></strong></font></td></tr>';
    echo '<tr><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Confirmar Contraseña:</td><td><input name="password2" type="password" id="password2" value="'.htmlspecialchars($_POST['password2']).'"></td></tr>';
	echo '<tr><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Grupo:</td><td>
	<select name="user_level" id="user_level">
    <option value="Arthropod">Arthropod</option>
    <option value="Mollusca">Mollusca</option>
    <option value="Chordata">Chordata</option>
  </select>';
	echo '<tr><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong> </td><td><input type="submit" value="Submit" name="submit" ></strong></font></td></tr>';
    echo '</table>';
    echo '</form>';
?>
Many thanks

Jim

Posted: Fri May 09, 2003 3:12 am
by m3mn0n

Posted: Fri May 09, 2003 4:16 am
by []InTeR[]
If you do this in javascript, a form object has a value 'DefaultValue'.
I think you know what that will be. :)