If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Form w/ 2 buttons - which was pressed

I have a form which has 2 buttons that can be pressed (New and update). Both should trigger the form submit after changing the value of a hidden field in the form. Is there a way to use a single function to fill in the value by determining which button was pressed, or do I have to write 2 different function with the same basic code?

If your user clicks on <input type="submit" name="fooButton" value="foo"/>, then the request will include the parameter "fooButton=foo", similarly for any other submit button in the same form ... so theoretically you don't need any other client-side code to determine which button was pressed.

Thanks, I'm not sure why, but I'm still not getting what I think I should. I am using action="post" in my form. Can someone please look at this code:

dim newUpdate
if Request.Form("new")<>null then
//Set up blank form for entering data
newUpdate = "new"
elseif Request.Form("update")<>null then
//Call the Update query on the database with the updated values
newUpdate = "update"
else
//Display the current item
end if

I am using VBScript in case you're wondering. When I click the "new" or the update button, and display the value of newUpdate, I get newUpdate=