Microsoft KB Archive/164497

{|
 * width="100%"|

PRB: Cannot Dynamically Set form.action in Internet Explorer 3.x

 * }

Q164497

-

The information in this article applies to:


 * Microsoft Internet Explorer (Programming) versions 3.0, 3.01, 3.02

-

SYMPTOMS
In the versions of Internet Explorer listed above, setting the action property of a form does not result in the new value being used when the form is submitted. Instead the original value is used.

CAUSE
This behavior is by design.

RESOLUTION
Either all form processing must done with the same action or additional hidden forms must be used, one for each possible action. An example of this is given below.

NOTE: Setting the form action dynamically is supported in Internet Explorer 4.0 and later.

Steps to Reproduce Behavior
The following page contains a form with the action set to Action1.asp. When the Change button is clicked, a JScript function is called that is intended to change the action of the form to Action2.asp.

In the Internet Explorer versions listed above, the form is submitted to Action1.asp regardless of whether the change button was clicked.



 Form Action Example 

 

  The Form.Action for this page is originally set to action1.asp. Click the change button to change the action property to action2.asp.  Click the submit button to see which action URL is accessed.  Current Form Action:    <INPUT TYPE="Submit"> </FORM> </BODY> </HTML> Put the following two Active Server Pages (ASP) files into the same directory as the HTML page above:

Action1.asp

<pre class="CODESAMP"><%@ Language=VBScript %> <HTML>  Test Action Page 1</TITLE> </HEAD> <BODY> <H2>Action 1</H2></BR> <% Response.Write "<H3>Form [POST] items : " & Request.form.count & "</H3><BR/>" for each rItem in Request.Form Response.Write ( rItem & " : " & Request.form(ritem) & "<BR/>") next %> </BODY> </HTML> Action2.asp

<pre class="CODESAMP"><%@ Language=VBScript %> <HTML>  Test Action Page 2</TITLE> </HEAD> <BODY> <H2>Action 2</H2><BR/> <% Response.Write "<H3>Form [POST] items : "_ & Request.form.count & "</H3><BR/>" for each rItem in Request.Form Response.Write ( rItem & " : " & Request.form(ritem) & "<BR/>") next %> </BODY> </HTML>

Workaround
The following sample illustrates the idea of using additional hidden forms to change the action of the form:

<pre class="CODESAMP"><HTML>  Form Action Example</TITLE> <SCRIPT LANGUAGE="JavaScript">

</SCRIPT> </HEAD> <BODY onload="update_field"> This page illustrates using the multiform approach to solve the problem of not being able to change the form action in Internet Explorer 3.

Note that the submit is a normal HTML input button and not a true submit button. <FORM NAME="MyFm1" METHOD=POST ACTION="action1.asp"> Current Form: <INPUT TYPE="text" name="FormAction"> <BR/><BR/> <INPUT TYPE="Button" VALUE="Change" onClick="change;"> <INPUT TYPE="Button" Value="Submit" onClick="do_submit;"> </FORM>

<FORM NAME="MyFm2" METHOD=POST ACTION="action2.asp"> <INPUT TYPE="hidden" name="FormAction"> </FORM> </BODY> </HTML> Additional query words:

Keywords : kbprogramming kbIE300 kbIE301 kbIE302 kbGrpDSInet kbDSupport

Issue type : kbprb

Technology : kbIEsearch kbAudDeveloper kbSDKIESearch kbSDKIE300 kbSDKIE301 kbSDKIE302