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?
The name/value pair of the clicked button will be passed to the server script.
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:
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"
//Display the current item
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=
If your buttons have these name and value the value will be received
<button type="submit" name="submit" value="new">new</button>
<button type="submit" name="submit" value="update">update</button>
OK, thanks for the help. I got it working now.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)