p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_forms thread: Submit buttons on FORMS


Message #1 by "Simon Hesford" <simonhesford@y...> on Tue, 16 Jan 2001 10:18:02 -0000
Is it possible to have two submit buttons on one form and depending on

which one is clicked the form data will be posted to a different web page?



Simon

Message #2 by Sebina Rosbergen <SR@x...> on Tue, 16 Jan 2001 11:25:06 +0100
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C07FA6.98F59E4A

Content-Type: text/plain;

	charset="iso-8859-1"



Yes, that is possible by defining OnClick events for both buttons in which

you set the form's action property. Subsequently you call the form's submit

method.

For example:



Sub btn1_Onclick()

frmContract.action = "xx.asp"

frmContract.submit()

end sub



Good luck!





Sebina Rosbergen-Heida





-----Original Message-----

From: Simon Hesford [mailto:simonhesford@y...]

Sent: dinsdag 16 januari 2001 19:35

To: ASP Forms

Subject: [asp_forms] Submit buttons on FORMS





Is it possible to have two submit buttons on one form and depending on

which one is clicked the form data will be posted to a different web page?



Simon



---

http://www.asptoday.com - the leading site for timely,

in-depth information for ASP developers everywhere.







Message #3 by John Pirkey <mailjohnny101@y...> on Tue, 16 Jan 2001 08:10:20 -0800 (PST)
sort of - try this scenario:



one form, two submit buttons.  since the form definition defines where the data is

sent, only one location can be used with one form tag.  so, build a "staging" asp

page to determine which button was clicked.  lets say you have the following form:

<form action=mypage.asp method=post>

<input type=text name=txtname>

<input type=submit name=cmdsubmit value='First Name'>

<input type=submit name=cmdsubmit value='Last Name'>

</form>



notice that both submit buttons have the same name, this allows us to check the

value and compare it against something.  try this in the mypage.asp (where the form

posts to)



If lcase(Request.Form("cmdsubmit")) = "first name" then

   'the first name button was clicked - call the firstname routine

   Call FillFirstName(request.form("txtname"))

elseif lcase(request.form("cmdsubmit")) = "last name" then

   'the last name button was clicked - call the lastname routine

   Call FinishName(request.form("txtname"))

end if



hope this makes sense and helps,



john

   



--- Simon Hesford <simonhesford@y...> wrote:

> Is it possible to have two submit buttons on one form and depending on

> which one is clicked the form data will be posted to a different web page?

> 

> Simon

> 

> 





=====



---------------------------- 

John Pirkey 

MCSD 

John@S... 

http://www.stlvbug.org



Message #4 by "Lundy, Alalia" <LundyA@m...> on Tue, 16 Jan 2001 12:11:24 -0500
I got the following 2 button submit code from

http://www.programmersresource.com/tips/tip044.asp



<form method="put" action="">



...



<INPUT Type=Submit Value="Add Record"

onClick="this.form.action='addrecord.asp';"> 



<INPUT Type=Submit Value="Del Record"

onClick="this.form.action='deleterecord.asp';"> 



</form> 



-----Original Message-----

From: Simon Hesford [mailto:simonhesford@y...]

Sent: Tuesday, January 16, 2001 1:35 PM

To: ASP Forms

Subject: [asp_forms] Submit buttons on FORMS





Is it possible to have two submit buttons on one form and depending on

which one is clicked the form data will be posted to a different web page?



Simon



Message #5 by "Michael Goldman" <mg188@h...> on Tue, 16 Jan 2001 09:48:48 -0800
I think you can do this if each set of code, submit, and reset buttons are

within a set of form tags.  Try it on a test page.



Alternatively, you can set a conditional to choose which page the form posts

to:



if  SomeCondition then

response.write "<form name= 'thing' action='page4.asp' method='post'>"

else

response.write "<form name= 'thing' action='page5.asp' method='post'>"

end if



I use this on some of my pages - very handy for splitting up functional

parts of an app into several pages.





----- Original Message -----

From: "Simon Hesford" <simonhesford@y...>

To: "ASP Forms" <asp_forms@p...>

Sent: Tuesday, January 16, 2001 10:34 AM

Subject: [asp_forms] Submit buttons on FORMS





> Is it possible to have two submit buttons on one form and depending on

> which one is clicked the form data will be posted to a different web page?

>

> Simon

>

Message #6 by "Simon Hesford" <simonhesford@y...> on Wed, 17 Jan 2001 10:23:03 -0000
Thanks for all the suggestions they have proved to be very useful.



Cheers,

Simon


  Return to Index