[thelist] reseting a form (with a twist)

.jeff jeff at members.evolt.org
Fri Mar 1 12:44:01 CST 2002


nick,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Nick Wilson
>
> Okay, not as simple as it sounds.  A reset button on my
> form will not work as the values of the form fields are
> php oject properties that are in the current session.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

sure it will.  it'll do exactly what it was designed to do -- return the
form fields to their default values.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> So I need to make my reset button destroy the session
> vars or reset them to "". I thought maybe it could be
> a submit that would include a hidden field that would
> set the 'mode' to reset (the mode is just another var
> like validate, success and error)
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

sounds like you've already got the solution in hand, though it needn't be so
complicated.  just make the reset button a regular submit.  in your
server-side code, check for this particular form field with a of "Reset".
if it's present, just change your mode.  the easiest is if you name all your
submit buttons "submit".  then you just have to check the value of the same
field to determine what action you should take.

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list