Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Two submit buttons within one <form>

Reply
Thread Tools

Two submit buttons within one <form>

 
 
Mike P
Guest
Posts: n/a
 
      08-14-2008
Can you have 2 submit buttons in one <form> element? I have a form with
a few dropdowns and textboxes that has a submit button to write the data
to a database, but I also need a submit button next to one of the
dropdowns to respond to whatever has been selected in the dropdown,
which will then populate one of the text boxes. How can I do this?


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-14-2008
Mike P wrote:
> Can you have 2 submit buttons in one <form> element?


I don't see why not, but I've never tried it. Why don't you try it and let
us know?

> I have a form
> with a few dropdowns and textboxes that has a submit button to write
> the data to a database, but I also need a submit button next to one
> of the dropdowns to respond to whatever has been selected in the
> dropdown, which will then populate one of the text boxes. How can I
> do this?
>

Well, a second submit button will submit the same form as the first one, so
you will need to provide some way for the target page to tell whether to
simply provide the information for your cascading dropdown or to write the
data to the database.

See here for some alternative approaches:
http://classicasp.aspfaq.com/forms/h...n-another.html

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      08-14-2008
Bob Barrows [MVP] wrote on 14 aug 2008 in
microsoft.public.inetserver.asp.general:

> Mike P wrote:
>> Can you have 2 submit buttons in one <form> element?

>
> I don't see why not, but I've never tried it. Why don't you try it and
> let us know?
>
>> I have a form
>> with a few dropdowns and textboxes that has a submit button to write
>> the data to a database, but I also need a submit button next to one
>> of the dropdowns to respond to whatever has been selected in the
>> dropdown, which will then populate one of the text boxes. How can I
>> do this?
>>

> Well, a second submit button will submit the same form as the first
> one, so you will need to provide some way for the target page to tell
> whether to simply provide the information for your cascading dropdown
> or to write the data to the database.
>


<f...='post'.....
<input type='submit' name='mySubmit' value='number1'>
<input type='submit' name='mySubmit' value='number2'>

............

<%
if request.form("mySubmit")="number1" then
'' first one pressed
elseif request.form("mySubmit")="number2" then
'' other one pressed
else
'' possibly js triggered: d...form[x].submit();
end if

not tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms with multiple submit buttons vs 'form' objects with single 'submit' methods neil.fitzgerald@ic.ac.uk Python 4 04-14-2006 04:58 PM
Two submit buttons, can each call its own action? Fernie HTML 9 12-05-2004 07:09 PM
Two submit buttons, which one was pressed? actionwoman63 Javascript 3 11-23-2004 10:48 PM
how to add two submit buttons to a form in struts sree Java 2 04-28-2004 02:12 PM
Multiple asp:buttons on one form but ONLY one should submit? D. Shane Fowlkes ASP .Net 3 02-24-2004 12:17 PM



Advertisments