retaining previously entered values in list/menu box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jarow
Forum Commoner
Posts: 83
Joined: Tue Jan 28, 2003 2:58 am

retaining previously entered values in list/menu box

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

If you do this in javascript, a form object has a value 'DefaultValue'.
I think you know what that will be. :)
Post Reply