p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

proasp_codeclinic thread: Different action for the same form

Message #1 by "COCO LUA SUAT CHOO" <cocolua@h...> on Tue, 05 Jun 2001 08:31:53
That's all very well, but it requires javascript, and I feel compelled to
provide a solution in ASP as this is an ASP list ;)

<form method=3D"post" action=3D"process.asp">
<input type=3D"submit" name=3D"action" value=3D"Add">
<input type=3D"submit" name=3D"action" value=3D"Delete">

if Request("action") =3D "Add" then

         'add form data to db

elseif Request("action") =3D "Delete" then

         'delete form data from db


         'nothing to process, send user back

end if

So basically I am using the label of the button to find out which submit
button was pressed. If you prefer, you can have index.asp post the form
data to itself, and then, depending on what was pressed, do a
response.redirect to a URL constructed as if it had been sent by a form
using GET, e.g.:-

redirecturl =3D "edit_sports_events.asp?sportid=3D" &



At 20:50 05/06/01 +0100, you wrote:
><form name=3D"sampleForm" method=3D"post">
><input type=3D"button" value=3D"save"
><input type=3D"button" value=3D"delete"
>At 08:31 05/06/01 +0000, you wrote:
>>How can i make my form to have different actions
>>Here's the case i have a form with several text input, when user hit go
>>button it will retrieve the info from thd DB and display, and when Add
>>button is entered, another .asp file should be called to performed action.
>>how to do that since we usually provide only one action for one form

  Return to Index