devxlogo

Reading Across Mulitple Forms on One ASP Page

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")
See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist