Reading Across Mulitple Forms on One ASP Page

Question:

I have two forms on my ASP page. The first form uses the &qout;Post” Method and second uses the &qout;Get” Method. The form using the “Get” method has a textbox with a value. How can I get the “Post” form to read the value of textbox in the “Get” form?

Answer:

When your form is submitted, it cannot view any information from the other form. Only the form that is being submitted sends its values over.

However, using client side Javascript, you can make sure that form1 sends form2’s textbox value when it is submitted.

In the form tag, include the code:

... your form contents

Assume you have defined the second form with a name of “form2” and it has a text box called “text1”. Use the following Javascript code anywhere on your page, preferably in the section.

In your “Whatever” ASP page that responds to the POST form’s submit action, you can read the value of the form’s variables by using:

   var = Request("variablename")

The value of the other text box will now be available as:

var = Request("OtherTextBox")
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: