dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Intermediate
Jul 12, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Submitting Forms to Different Pages

An HTML form usually looks like this:

 
<form name="Form1" method="post" action="page1.asp">

where you have to specify the action within the Form tag, thus limiting a "post" method to only one destination. However, the JavaScript form object has an "action" property that lets you dynamically change the destination of a "post" method. This is helpful, for example, on a data form page where you have buttons to add, remove, or update records, and the code for each action is located in separate ASP files. This example demonstrates how to change the action dynamically.

 
<html>
<head>
<script language=javascript>
function submitTo(url){
        document.Form1.action = url
        document.Form1.submit();
}
</script>
</head>
<body>
<form name="Form1" METHOD=POST>
<p><input type=text name=text1 value="page2.asp">
<p><input type=button value="Submit" onClick="submitTo(text1.value)">
</form>
</body>
</html>

Note: This technique will not work in Internet Explorer 3.0. While it does not give you a run-time error, the action property cannot be set dynamically.

William Wen
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date