Click to See Complete Forum and Search --> : Button Problem
rathnadevil
September 4th, 2002, 08:48 AM
Hi,
I want to use three 'Submit' buttons on a form for three different actions. Is it possible to identify which button the user has clicked?
Or please let me know some other alternative solution to this problem.
Thanks
tresesert
September 4th, 2002, 10:09 AM
I believe there is an onClick event associated with buttons in forms. If you are using jsp to perform some action associated with the button, you could call it directly from there, call a function that would set a variable or redirect it to an html link. I don't know if this would work, but in theory I think it would look like this:
<FORM>
<INPUT TYPE="BUTTON" VALUE="Validate"
ONCLICK="performvalidate();">
<INPUT TYPE="BUTTON" VALUE="Email"
ONCLICK="www.hotmail.com">
<INPUT TYPE="BUTTON" VALUE="Submit"
ONCLICK="submit();">
</FORM>
I am unsure if there is a method associated to let you directly know which button has been clicked, like there is in java. Hope this helps. If I'm way off, let me know, maybe I can clarify.
tresesert
September 4th, 2002, 10:13 AM
This is another snippet of code I found that might be of use to you:
<FORM ACTION="foldoc.cgi">
<INPUT TYPE="SUBMIT" NAME="action" VALUE="Home">
<INPUT TYPE="SUBMIT" NAME="action" VALUE="Contents">
<INPUT TYPE="SUBMIT" NAME="action" VALUE="Feedback">
<INPUT TYPE="SUBMIT" NAME="action" VALUE="Random">
<INPUT NAME="query">
<INPUT TYPE="SUBMIT" NAME="action" VALUE="Search">
</FORM>
dgobrien
September 4th, 2002, 10:32 AM
Do you want to post in all cases, or do you want to handle some of the clicks on the client? I don't know which browsers you're targeting, but it's really easy in IE. Use the onclick method on each button to set a hiddent input, and then call form.submit(). Or do it in the form's onSubmit handler. If you get stuck let me know.
pmmbala
September 5th, 2002, 06:27 AM
hi
for which button clicked..like this u can check it
if Request.Form("button1") <> "" then doprocess1()
if Request.Form("button2") <> "" then doprocess2()
if Request.Form("button2") <> "" then doprocess3()
sub doprocess1()
---- some code
end sub
sub doprocess2()
-------- some code
end sub
sub doprocess3()
---- some code
end sub
Thanks
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.