Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Submit buttons in one form 1

Status
Not open for further replies.

SlykFX

Programmer
Oct 12, 2002
76
GB
i have a form and i need to use several submit buttons to submit the form so that the input will be sent to the correct sub

i have one text box and 3 submit buttons and depending on which submit button is pressed, i want the correct subroutine to be run to query the correct table in my db

basically in simple language, how do i find out which submit button was used on the ASP form processing page?

any help offered will be much appreciated
thanks in advance

I can't be bothered to have a sig!
 
Name them all the same name like "btnSubmit". I assume that they will have different value attributes because they are going to do different things, right? Example:
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Add&quot; OnClick=&quot;Whatever1()&quot;>
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Edit&quot; OnClick=&quot;Whatever2()&quot;>
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Quit&quot; OnClick=&quot;Whatever3()&quot;>

On the processing page:
<%
myButton = request.form(&quot;btnSubmit&quot;)
Select Case myButton
CASE &quot;Add&quot;
'Do stuff here
CASE &quot;Edit&quot;
'Do other stuff here
CASE &quot;Quit&quot;
'Do even other stuff here
END SELECT
%>
 
if possible i would prefere them to have the same values
the reason for this is becuase they do do the same things but it will be on different records

if this is not possible then ill have to use different values

I can't be bothered to have a sig!
 
value attribute doesn't effect anything but to confuse the user

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
Suppose I should clarify that.

how's the user going to know what to press if they all have the same value?

There would be know unique way to find out what was pressed if you did that though. unless you name the submits with unique names

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
I generally don't show my users (or my project managers) something like this:
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Submit&quot; OnClick=&quot;Whatever1()&quot;>
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Submit&quot; OnClick=&quot;Whatever2()&quot;>
<input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Submit&quot; OnClick=&quot;Whatever3()&quot;>

It's kind of hard to explain. ;-)
 
I know why you wouldn't show them [lol]

you want to add those function calls to the form tag with a onSubmit=&quot;return

just pointing out cause javascript (if thats the client script) is irritatingly case sensitive so the call would be onClick



1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
actually the onSubmit wouldn't work unless these were buttons. sorry!

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
the user wouldnt be confused about the operation of the buttons by them having the same values as they are to different records in a table

obviously they will have different names as each one is for one unique record

anyway thanks for the help, its some good reference, but what i will be using is this method found on &quot;Add 2nd Button to a form&quot; thread

if request(&quot;button1&quot;) <> &quot;&quot; then
' First Button Pressed
elseif request(&quot;button2&quot;) <> &quot;&quot; then
' 2nd button pressed
end if

I can't be bothered to have a sig!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top