PDA

View Full Version : Having 2 Buttons in 1 Form Tag


Abd
04-02-2003, 04:59 PM
Hi All,

pls is it possible to have two submit button pointing to two different .asp (action=---.asp) within one form tag element?

Abd

Vladdy
04-02-2003, 05:10 PM
With the help of javascript - yes. You change form.action using button's onclick.

raf
04-02-2003, 05:26 PM
http://www.codingforums.com/showthread.php?s=&threadid=17147

easiest way is just giving the submit buttons different values (but same name) and performing actions or a redirect on the page that the action points to, depending on the value for the submitbutton that was clicked (submit buttons have same name but different value)

Abd
04-03-2003, 06:40 AM
Hi raf,

any piece of code base on your suggestion, that is;

[easiest way is just giving the submit buttons different values (but same name) and performing actions or a redirect on the page that the action points to, depending on the value for the submitbutton that was clicked (submit buttons have same name but different value)]


Thanks
Abd

raf
04-03-2003, 07:20 AM
HTML code for the form

<form name="multiplesubmit" action="process.asp" method="post">
<input type="submit" value="delete" name="action">
<input type="submit" value="update" name="action">
</form>


VBscript code for in process.asp

if request.form("action") = "delete" then
your code that needs to be executed when button 1 is clicked
else
if request.form("action") = "update" then
your code that needs to be executed when button 2 is clicked
else
response.write("Error. How did you get to this page you ***. I've logged your IP and will take appropriate actions")
end if
end if

If you have more then 2 buttons, you probably best use a "select case" in stead of the "if then".

Abd
04-03-2003, 10:17 AM
Thanks raf

it worked

Abd