469,286 Members | 2,539 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

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='secondForm' 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 3066
Depends on which form you submitted.

ie you can only submit one form

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

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

</form>

<form name='secondForm' 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.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi.

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

</form>

<form name='secondForm' 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="javascript: document.firstForm.submit();"
onmouseover="document.firstForm.action='/myPage.asp?PAGE_ID=FIRSTFORM';">Sub
mit First Form</a>

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

</form>

<a href="javascript: document.secondForm.submit();"
onmouseover="document.secondForm.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("PAGE_ID")

If PAGE_ID=FIRSTFORM Then

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

End If

If PAGE_ID=SECONDFORM Then

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

End If

%>

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

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi.

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

</form>

<form name='secondForm' 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"
<djmarsatAThotmail.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="javascript: document.firstForm.submit();"
onmouseover="document.firstForm.action='/myPage.asp?PAGE_ID=FIRSTFORM';">Sub
mit First Form</a>

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

</form>

<a href="javascript: document.secondForm.submit();"
onmouseover="document.secondForm.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("PAGE_ID")

If PAGE_ID=FIRSTFORM Then

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

End If

If PAGE_ID=SECONDFORM Then

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

End If

%>

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

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi.

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

</form>

<form name='secondForm' 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 <djmarsatAThotmail.com> wrote in message
news:uw*************@TK2MSFTNGP09.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="javascript: document.firstForm.submit();"
onmouseover="document.firstForm.action='/myPage.asp?PAGE_ID=FIRSTFORM';">Sub mit First Form</a>

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

</form>

<a href="javascript: document.secondForm.submit();"
onmouseover="document.secondForm.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("PAGE_ID")

If PAGE_ID=FIRSTFORM Then

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

End If

If PAGE_ID=SECONDFORM Then

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

End If

%>

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

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi.

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

</form>

<form name='secondForm' 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******@REMOVETHISmentorcom.com> wrote in message
news:40****************@news.microsoft.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"
<djmarsatAThotmail.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="javascript: document.firstForm.submit();"


onmouseover="document.firstForm.action='/myPage.asp?PAGE_ID=FIRSTFORM';">Su

b
mit First Form</a>

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

</form>

<a href="javascript: document.secondForm.submit();"


onmouseover="document.secondForm.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("PAGE_ID")

If PAGE_ID=FIRSTFORM Then

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

End If

If PAGE_ID=SECONDFORM Then

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

End If

%>

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

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi.

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

</form>

<form name='secondForm' 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******@REMOVETHISmentorcom.com> wrote in message
news:40****************@news.microsoft.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******@REMOVETHISmentorcom.com> wrote in message
news:40****************@news.microsoft.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"
<djmarsatAThotmail.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="javascript: document.firstForm.submit();"


onmouseover="document.firstForm.action='/myPage.asp?PAGE_ID=FIRSTFORM';">Su

b
mit First Form</a>

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

</form>

<a href="javascript: document.secondForm.submit();"


onmouseover="document.secondForm.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("PAGE_ID")

If PAGE_ID=FIRSTFORM Then

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

End If

If PAGE_ID=SECONDFORM Then

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

End If

%>

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

Hope this helps, Dominic

"Chris Leffer" <ch****@wank.com> wrote in message
news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi.

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

</form>

<form name='secondForm' 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="somepage.asp">
<input name="x">
<input type="submit">
<input type="hidden" name="formID" value="1">
</form>

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

Ray at work

"dan tucker" <an*******@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.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
=?Utf-8?B?ZGFuIHR1Y2tlcg==?= wrote on 25 mrt 2004 in
microsoft.public.inetserver.asp.general:
could someone give a brief example of how to use a hidden value to
determine which form is being submitted?


<form id=formA>
<input type=hidden name=whichForm value="formAselected">
<input type=submit value=A>
</form>

<form id=formB>
<input type=hidden name=whichForm value="formBselected">
<input type=submit value=B>
</form>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by ElmoWatson | last post: by
3 posts views Thread by Kris van der Mast | last post: by
reply views Thread by Anonieko Ramos | last post: by
5 posts views Thread by Gavin Stevens | last post: by
6 posts views Thread by Manny Chohan | last post: by
5 posts views Thread by ~~~ .NET Ed ~~~ | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.