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]  Databases

Form Tricks #3:  Forms that Dynamically Change Action

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

Some forms need to vary their action.

   filename=/learn/test/FormActionChange.asp

<Test Script Below>


<html><head>
<title>FormTextBox.asp</title>
</head><body bgcolor="#FFFFFF">
<Form name="profile" action = "profilerespond.asp" 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>
    <a href="Javascript:army()">Join Army</a> 
    <a href="Javascript:navy()">Join Navy</a> 
    <a href="Javascript:marines()">Join Marines</a> 
</form>
</body></html>

<form name=myform> 
</form> 

<script language =javascript> 
function army(form) 
{ 
document.myform.action="joinarmy.asp" 
document.myform.submit() 
} 
function navy(form) 
{ 
document.myform.action="joinnavy.asp" 
document.myform.submit() 
} 
function marines(form) 
{ 
document.myform.action="joinmarines.asp" 
document.myform.submit() 
} 
</script> 

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site