Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Forms: For Each Iteration
     [next Lesson]  Form - Change Action on Fly

Form Tricks #2: Self-Submitting Forms

There are some clever tactics programmers can apply when dealing with forms. They have their drawbacks and should be used sparingly.

Some people prefer to combine their forms and actions in one file. I don't because of usability issues -- a user who refreshes a combined form will be presented with a confusing choice "repost form data (y/n)"  which they are not presented with if the forms are separate. Such a form could be submitted twice accidentally when they just meant to redisplay the form.

   filename=/learn/test/FormSubmitSelf.asp

<Test Script Below>


<html><head>
<title>FormSubmitSelf.asp</title>
</head><body bgcolor="#FFFFFF">
<%
SELECT CASE lcase(request.form("join"))
CASE "join"
    response.write "Thanks for joining "
    response.write request.form("namefirst") & "&nbsp;"
    response.write request.form("namelast") & "&nbsp;"
CASE ELSE
%>
<Form method="post">
    Fill Out This Form For Us:<p>
    First Name <Input NAME="NameLast" size ="10"><br>
    Last Name <Input NAME="NameLast" size ="10"><br>
    <input type="submit" name="Join" value="Join"> 
</form>
<%END SELECT%>
</body></html>

Send Us a Holiday Gift!. Charles celebrates Christmas, Jewish holidays, Kwanza, Chinese New Year, Japanese Holidays, Secretary Day, High Muslim Holy Days, Pagan & Wicca holidays, and many more! - send a gift any HOLIDAY. 2004 gift gallery & 2005 gift gallery