I've actually found a way to do this:
Instead of calling a function for each form that is submitted, I've come to learn that the values passed from input type="image" are the x and y coordinates. Having said that, if the button is not pressed, the coordinate = "".
Each time I submit a form I can check to see which of the button's values are not an empty string and do the code needed.
Here's a visual representation:
note: I also ran into a problem where I had 2 buttons per form (update, delete). This is also fixed with this code
HTML Code:
<form name="form1" id="form1" method="post" action="formHandler.asp">
<input type="image" src="imgs/pic1.gif" name="saveUser" id="saveUser" />
<input type="image" src="imgs/pic2.gif" name="deleteUser" id="deleteUser" />
</form>
<form name="form2" id="form2" method="post" action="formHandler.asp">
<input type="image" src="imgs/pic3.gif" name="saveCategory" id="saveCategory" />
<input type="image" src="imgs/pic4.gif" name="deleteCategory" id="deleteCategory" />
</form>
PHP Code:
Dim userSave, userDelete
'The .x gets the value of the x coordinate
userSave = Request.Form("userSave.x")
userDelete = Request.Form("userDelete.x")
If userSave <> "" Then
Response.Write "User Saved"
End If
If userDelete <> "" Then
Response.Write "User Deleted"
End If
So, regardless of how many buttons and forms I have, I can also see which button is pressed.
Bookmarks