Como Capturar multiples submit

Topics: Developer Forum
Apr 18 at 1:05 PM
I wonder if anyone can help me on how to capture which submit button was pressed in a multipart forms submit buttons. I 'm trying to do with the following code :

cvar = orequest.form("button1")
if !empty(cvar)
* secuense
endif

cvar2 = orequest.form("button2")
if !empty(cvar2)
* secuense
endif

But I always run sequence by more than button1 button2 pressed .
Coordinator
Apr 18 at 8:15 PM
That will not work because no matter how the form gets submitted, all buttons will be included in the form's data. I think you must not use submit buttons but regular buttons, linked to particular js functions and then manually submit the form from inside those js functions. That way you could set the value of a hidden input so you can latter know which button was pressed.


Victor
Apr 25 at 6:51 PM
I've handled this type of scenario by having custom onclick code for each button. For example, my search button has the code onclick="document.forms[0].action = '<%=oProp.ScriptPath+[?action=] + oProp.Action + [&Search=1]%>';" and the actual submit button has the code onclick="document.forms[0].action = '<%=oProp.ScriptPath+[?action=] + oProp.Action + [&Submit=1]%>';"

When the page loads, it executes something like this:
<%
lcSubmit    = NVL(oRequest.QueryString("Submit"), [])
lcSearch    = NVL(oRequest.QueryString("Search"), [])

DO CASE
CASE NOT EMPTY(lcSubmit)
  *-- Submit code goes here

CASE NOT EMPTY(lcSearch)
  *-- Search code goes here
ENDCASE
%>