Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple buttons on form submit

Status
Not open for further replies.

Denster

Programmer
Joined
Apr 9, 2001
Messages
198
Location
GB
I have a simple form with 3 buttons depending what the user wants to do. One of the buttons is a Delete so I want to throw up a "confirm()" box when this button is pressed. I know how to do a confirm dialog if there was just one button on the form but what is the best way when there are a few buttons?.
 
You missunderstand, the form submission looks like this -
<form name="Sub" method="post" action="textfile.asp?PageUser=<%=CustomerId%>onsubmit="return submitForm();">
submitForm() is a validation function. I only want the confirm box to appear when the delete button is clicked. Idealy some coding would go in the validation function to detect which button has been clicked.
 
No - I did understand - you just didn't explain with enough clarity. You said simply "buttons", not "submit buttons". Buttons do not cause a form to submit unless programmed to do do. Submit buttons do.

Having said that, the anwwer is in that rant ;-)... simply make your delete submit button a regular button with an onclick that calls the alert, and then if the value is affirmative, call the form submit method.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Oh yes - if you choose that route (for there are others), you'll need to call your validation routine manually before submission, as calling the form's submit event bypassed the onsubmit handler.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Ok thanks Dan! Will let you know how I get on.



Den

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top