473,698 Members | 2,198 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two forms in asp page

Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
10 3397
Depends on which form you submitted.

ie you can only submit one form

--
Roji. P. Thomas
SQL Server Programmer
"Chris Leffer" <ch****@wank.co m> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2
Don't give the fields the same "name" in both forms........?

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Chris Leffer <ch****@wank.co m> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #3
Chris,

Try the following using Javascript, although you will require two submit
links,
one for each form. Ideally, you should try to stick to one form per page.

*************** ASP page with Forms *************** ***************

<form method="post" name="firstForm ">

</form>

<a href="javascrip t: document.firstF orm.submit();"
onmouseover="do cument.firstFor m.action='/myPage.asp?PAGE _ID=FIRSTFORM'; ">Sub
mit First Form</a>

<form method="post" name="secondFor m">

</form>

<a href="javascrip t: document.second Form.submit();"
onmouseover="do cument.secondFo rm.action='/myPage.asp?PAGE _ID=SECONDFORM' ;">S
ubmit Second Form</a>

*************** *************** *************** *************** ******

On the myPage.asp you will need to identify which form has been
submitted, I've done this with a querystring, so you'll need to get the
value of the querystring then use that to determine which request.form
actions to do. so.....

*************** *** myPage.asp *************** *************** ******

<%

PAGE_ID=Request .Querystring("P AGE_ID")

If PAGE_ID=FIRSTFO RM Then

Request.Form("b lah1")
Request.Form("b lah2")
Request.Form("b lah3")

End If

If PAGE_ID=SECONDF ORM Then

Request.Form("b lah4")
Request.Form("b lah5")
Request.Form("b lah6")

End If

%>

*************** *************** *************** *************** ******

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.co m> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #4
Dominic,

Why do something that complicated when you all you would have to do to
accomplish the same result, with no javascript, is to put in a hidden
field in each form with the form name?

Keep it simple!

Jeremy

On Wed, 24 Mar 2004 15:19:26 -0000, "Dominic Marsat"
<djmarsatAThotm ail.com> wrote:
Chris,

Try the following using Javascript, although you will require two submit
links,
one for each form. Ideally, you should try to stick to one form per page.

************** * ASP page with Forms *************** ***************

<form method="post" name="firstForm ">

</form>

<a href="javascrip t: document.firstF orm.submit();"
onmouseover="d ocument.firstFo rm.action='/myPage.asp?PAGE _ID=FIRSTFORM'; ">Sub
mit First Form</a>

<form method="post" name="secondFor m">

</form>

<a href="javascrip t: document.second Form.submit();"
onmouseover="d ocument.secondF orm.action='/myPage.asp?PAGE _ID=SECONDFORM' ;">S
ubmit Second Form</a>

************** *************** *************** *************** *******

On the myPage.asp you will need to identify which form has been
submitted, I've done this with a querystring, so you'll need to get the
value of the querystring then use that to determine which request.form
actions to do. so.....

************** **** myPage.asp *************** *************** ******

<%

PAGE_ID=Reques t.Querystring(" PAGE_ID")

If PAGE_ID=FIRSTFO RM Then

Request.Form(" blah1")
Request.Form(" blah2")
Request.Form(" blah3")

End If

If PAGE_ID=SECONDF ORM Then

Request.Form(" blah4")
Request.Form(" blah5")
Request.Form(" blah6")

End If

%>

************** *************** *************** *************** *******

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.co m> wrote in message
news:O4******* *******@TK2MSFT NGP09.phx.gbl.. .
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Jul 19 '05 #5
Thats making it way more complicated than it needs to be.

The easiest is having it all in one "form" and using a querystring to pass
the action that tells your processing script, which form is being submitted,
then using an "If Then" or Select Case, to do the rest.

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Dominic Marsat <djmarsatAThotm ail.com> wrote in message
news:uw******** *****@TK2MSFTNG P09.phx.gbl...
Chris,

Try the following using Javascript, although you will require two submit
links,
one for each form. Ideally, you should try to stick to one form per page.

*************** ASP page with Forms *************** ***************

<form method="post" name="firstForm ">

</form>

<a href="javascrip t: document.firstF orm.submit();"
onmouseover="do cument.firstFor m.action='/myPage.asp?PAGE _ID=FIRSTFORM'; ">Sub mit First Form</a>

<form method="post" name="secondFor m">

</form>

<a href="javascrip t: document.second Form.submit();"
onmouseover="do cument.secondFo rm.action='/myPage.asp?PAGE _ID=SECONDFORM' ;">S ubmit Second Form</a>

*************** *************** *************** *************** ******

On the myPage.asp you will need to identify which form has been
submitted, I've done this with a querystring, so you'll need to get the
value of the querystring then use that to determine which request.form
actions to do. so.....

*************** *** myPage.asp *************** *************** ******

<%

PAGE_ID=Request .Querystring("P AGE_ID")

If PAGE_ID=FIRSTFO RM Then

Request.Form("b lah1")
Request.Form("b lah2")
Request.Form("b lah3")

End If

If PAGE_ID=SECONDF ORM Then

Request.Form("b lah4")
Request.Form("b lah5")
Request.Form("b lah6")

End If

%>

*************** *************** *************** *************** ******

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.co m> wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 19 '05 #6
I love the "Keep in Simple" idea!! It is my own mantra. However it can be
done with just a very small piece of JavaScript (even less than is shown in
these post), so it can be very simple with even the JavaScript.
--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
"Jeremy Markman" <jm******@REMOV ETHISmentorcom. com> wrote in message
news:40******** ********@news.m icrosoft.com...
Dominic,

Why do something that complicated when you all you would have to do to
accomplish the same result, with no javascript, is to put in a hidden
field in each form with the form name?

Keep it simple!

Jeremy

On Wed, 24 Mar 2004 15:19:26 -0000, "Dominic Marsat"
<djmarsatAThotm ail.com> wrote:
Chris,

Try the following using Javascript, although you will require two submit
links,
one for each form. Ideally, you should try to stick to one form per page.

************** * ASP page with Forms *************** ***************

<form method="post" name="firstForm ">

</form>

<a href="javascrip t: document.firstF orm.submit();"


onmouseover="d ocument.firstFo rm.action='/myPage.asp?PAGE _ID=FIRSTFORM'; ">Su

b
mit First Form</a>

<form method="post" name="secondFor m">

</form>

<a href="javascrip t: document.second Form.submit();"


onmouseover="d ocument.secondF orm.action='/myPage.asp?PAGE _ID=SECONDFORM' ;">

S
ubmit Second Form</a>

************** *************** *************** *************** *******

On the myPage.asp you will need to identify which form has been
submitted, I've done this with a querystring, so you'll need to get the
value of the querystring then use that to determine which request.form
actions to do. so.....

************** **** myPage.asp *************** *************** ******

<%

PAGE_ID=Reques t.Querystring(" PAGE_ID")

If PAGE_ID=FIRSTFO RM Then

Request.Form(" blah1")
Request.Form(" blah2")
Request.Form(" blah3")

End If

If PAGE_ID=SECONDF ORM Then

Request.Form(" blah4")
Request.Form(" blah5")
Request.Form(" blah6")

End If

%>

************** *************** *************** *************** *******

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.co m> wrote in message
news:O4******* *******@TK2MSFT NGP09.phx.gbl.. .
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 19 '05 #7

"Jeremy Markman" <jm******@REMOV ETHISmentorcom. com> wrote in message
news:40******** ********@news.m icrosoft.com...
Dominic,

Why do something that complicated when you all you would have to do to
accomplish the same result, with no javascript, is to put in a hidden
field in each form with the form name?

Keep it simple!

Jeremy


My thoughts exactly,
when I end up with several forms in one ASP page, I tend to provide an
hidden field indicating what action needs to be performed once submitted.
Basically I then have a Select Case statement which checks for the value of
the action to perform submitted in the form, which then calls the
appropriate functions which handles the action.

Jul 19 '05 #8
Aye, a hidden field in each form would be much simpler!

"Jeremy Markman" <jm******@REMOV ETHISmentorcom. com> wrote in message
news:40******** ********@news.m icrosoft.com...
Dominic,

Why do something that complicated when you all you would have to do to
accomplish the same result, with no javascript, is to put in a hidden
field in each form with the form name?

Keep it simple!

Jeremy

On Wed, 24 Mar 2004 15:19:26 -0000, "Dominic Marsat"
<djmarsatAThotm ail.com> wrote:
Chris,

Try the following using Javascript, although you will require two submit
links,
one for each form. Ideally, you should try to stick to one form per page.

************** * ASP page with Forms *************** ***************

<form method="post" name="firstForm ">

</form>

<a href="javascrip t: document.firstF orm.submit();"


onmouseover="d ocument.firstFo rm.action='/myPage.asp?PAGE _ID=FIRSTFORM'; ">Su

b
mit First Form</a>

<form method="post" name="secondFor m">

</form>

<a href="javascrip t: document.second Form.submit();"


onmouseover="d ocument.secondF orm.action='/myPage.asp?PAGE _ID=SECONDFORM' ;">

S
ubmit Second Form</a>

************** *************** *************** *************** *******

On the myPage.asp you will need to identify which form has been
submitted, I've done this with a querystring, so you'll need to get the
value of the querystring then use that to determine which request.form
actions to do. so.....

************** **** myPage.asp *************** *************** ******

<%

PAGE_ID=Reques t.Querystring(" PAGE_ID")

If PAGE_ID=FIRSTFO RM Then

Request.Form(" blah1")
Request.Form(" blah2")
Request.Form(" blah3")

End If

If PAGE_ID=SECONDF ORM Then

Request.Form(" blah4")
Request.Form(" blah5")
Request.Form(" blah6")

End If

%>

************** *************** *************** *************** *******

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.co m> wrote in message
news:O4******* *******@TK2MSFT NGP09.phx.gbl.. .
Hi.

If I have two forms in the same asp page:
<form name='firstForm ' action='myPage. asp'>

</form>

<form name='secondFor m' action='myPage. asp'>

</form>

When using request.form, how can I get values from a specific form?

Regards,
Chris Leffer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 19 '05 #9
<form method="post" action="somepag e.asp">
<input name="x">
<input type="submit">
<input type="hidden" name="formID" value="1">
</form>

<form method="post" action="somepag e.asp">
<input name="x">
<input type="submit">
<input type="hidden" name="formID" value="2">
</form>
somepage.asp:
<%
Response.Write "You submitted form " & Request.Form("f ormID")
%>

Ray at work

"dan tucker" <an*******@disc ussions.microso ft.com> wrote in message
news:B2******** *************** ***********@mic rosoft.com...
could someone give a brief example of how to use a hidden value to determine which form is being submitted?
Thnks,

Ol dan

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4830
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms Authentication set up and it worked just fine. Then I realized that I needed to have some pages unsecure. I then created 2 directories. One named Secure and the other named Public. I placed my web.config file in my
11
3579
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get any requested page to automatically go to the Login.aspx page, AND, the ReturnURL querystring is correct in the address bar, but no matter what, I can't get it, once the user is authenticated, to redirect to the new page. It ALWAYS refreshes the...
3
4866
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be protected by forms authentication. When I create forms authentication at root level it works but when I move my code up to the subfolder I get this error: Server Error in '/TestProjects/FormsAuthenticationTestingArea' Application.
0
4233
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com. --------------------------------------------------------------------------------
5
2874
by: Gavin Stevens | last post by:
I'm trying to figure out the ASP.NET Forms Auth I have 3 or 4 pages i want to allow anonymous access to.. Then I have 5 or 6 pages I placed in another directory in the webproject. These I want to manually authenticate users to provide acess My project has 2 web.config files... the default file <authentication mode="Forms"><forms loginUrl="Login.aspx" protection="All" timeout="30"...
4
5629
by: 23s | last post by:
I had this problem in the past, after a server reformat it went away, and now after another server reformat it's back again - no clue what's doing it. Here's the flow: Website root is public, no SSL no forms auth. One of the subfolders in the public area is the root of a "protected" area; SSL is required from this subfolder on forward and a web.config in the subfolder specifies forms authentication. From the public area, I provide a...
6
517
by: Manny Chohan | last post by:
I am using forms authetication in the web config. i can validate a user against a database and click on images which makes hidden panels visible.However when i click on the link inside a panel which should take user to another pages, it defaults them back to the login page prompting them to enter username and password. Could someone please shed some light on this on how i can fix this issue? Thanks Manny
5
5330
by: ~~~ .NET Ed ~~~ | last post by:
Hi, As you all know when an ASP.NET web form is created that will include web controls and such, it contains a FORM that that identifies the web form and its containing controls. Well, I have a web form who has several other (user & custom) controls, these are enclosed within the standard FORM tag. Additionally *some* of these user controls are actually forms as well. This results into nested Forms.
7
2449
by: Alan Silver | last post by:
Hello, Sorry this is a bit wordy, but it's a pretty simple question... I have a web site, http://domain/ which is a public site, part of which (http://domain/a/) is protected by forms authentication. I would like to configure it so that anyone not logged in, trying to access the protected part will not be redirected to the login page, but
5
14123
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.