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>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.