If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Using Multiple Submit buttons in a single form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-05, 06:56
Sunday Ironfoot Sunday Ironfoot is offline
Registered User
 
Join Date: Nov 2004
Location: Dundee, Scotland
Posts: 45
Question Using Multiple Submit buttons in a single form

I want to incorporate mutliple submit buttons for a single form, all buttons submit the same form and data, but process the form differently depending on which button was clicked.

Things is how does the calling ASP page that processes the form know which button was clicked? I'd image you use something like an IF button1 Then...ElseIf Button2 etc etc statement, but don't know the exact syntax.

Thanks!
__________________
Sunday Ironfoot

SQL Server 2000 n00b
Reply With Quote
  #2 (permalink)  
Old 03-06-05, 07:57
faamugol faamugol is offline
Registered User
 
Join Date: Mar 2004
Posts: 58
<HTML>
<BODY>

<%
btnID = "?"

if Request.Form("bsubmit") = "Submit 1" then
btnID = "1"
elseif Request.Form("bsubmit") = "Submit 2" then
btnID = "2"
elseif Request.Form("bsubmit") = "Submit 3" then
btnID = "3"
end if
%>
Submit button ID: <%=btnID%><BR>

<FORM action="mulsub.asp" method="post">
First name: <INPUT type="TEXT" name="FNAME"><BR>
<INPUT type="submit" name="bsubmit" value="Submit 1">
<INPUT type="submit" name="bsubmit" value="Submit 2">
<INPUT type="submit" name="bsubmit" value="Submit 3">
</FORM>

</BODY>
</HTML>
Reply With Quote
  #3 (permalink)  
Old 03-07-05, 17:34
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
My coding conventions sometimes look like this snippet:

' See what btn used, where opened from, or where referred from.
If Request.Form("btnClose") <> "" Then ' Close btn.
' Close.
Call ClosePg()
Elseif Request.Form("btnSave") <> "" Then ' Save btn.
' Set var.
Call SetVar("frompost")

' Save rec.
Call SaveRec()

' Show pg.
Call ShowPg()
Elseif Request.Form("btnNew") <> "" Then ' New btn from this pg.
' Set var.
Call SetVar("new")

' Show pg.
Call ShowPg()
Elseif Request.Form("btnDel") <> "" Then ' Del btn.
' Set var.
Call SetVar("frompost")

' Del rec.
Call DelRec()

' Set var.
Call SetVar("new")

' Show pg.
Call ShowPg()
Elseif Request.Form("btnShowList") <> "" Then ' ShowList btn.
' Set var.
Call SetVar("frompost")

' Show pg.
Call ShowPg()
Elseif Request.QueryString("CustID") <> "" Then ' CustID from Many pg.
Session(mstrSessionPrefix & "Cust-FromPg") = "custmany.asp"

' Set var.
Call SetVar("fromdb")

' Show pg.
Call ShowPg()
Elseif Request.QueryString("CustID") = "" Then ' Add btn from MainMenu pg.
Session(mstrSessionPrefix & "Cust-FromPg") = "mainmenu.asp"

' Set var.
Call SetVar("new")

' Show pg.
Call ShowPg()
Else ' Nothing.
' This should never be the case.
End If
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On