Multiple submit buttons for different things

Hey everyone, I’m working on an editor for a blog and part of the functionality is to be able to, in the same form, either save changes, delete the entry or cancel. Now, i can think of a dozen ways to do this in javascript :D, but i was wondering if there was any easy, non-complicated way to do this purely in HTML, with some attribute or something like that.

so in other words i’d like to have multiple submit buttons in the same form point to different actions. If its not possible without Javascript, i don’t have a problem with doing that, if thats the case just say so.

Here is the form code if it helps in anyway:

<form action="updateBlogPostHandler.php" method="post">
  <label>Post Title</label>
    <input name="blogtitle" value="<?php print $title; ?>" alt="Title" type="text" id="blogtitle" size="100" maxlength="150"  />
  <p><label>Blog Post</label></p>
    <textarea name="blogpost" value="<?php print $post; ?>" cols="100" rows="5" id="blogpost"></textarea>
  <input type="hidden" disabled="disabled" value="<?php $entry ?>" />
  <button type="submit">Save</button>
  <button type="submit">Delete</button>
  <button type="submit">Cancel</button>


Give the buttons a name and a value, and check which one has been sent in your php code.

Thank you

Give some extra thought on which is the first one. If the user is in the text field and hits enter, the system will assume the first submit button was hit.

Give them all different names and a value. They are only posted if they are clicked so you can do






You might find it easier to give all the submit buttons the same name but different values. Then check in your php code which value was sent which will tell you which submit button was clicked.

if (isset($_POST['btnSubmit'][0])) {
    switch (strtolower($_POST['btnSubmit'][0])) {
        case 'save':
            echo '<h1>Save button was clicked</h1>';
        case 'delete':
            echo '<h1>Delete button was clicked</h1>';
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <form action="#" method="post">
            <input type="submit" name="btnSubmit[]" value="Save" />
            <input type="submit" name="btnSubmit[]" value="Delete" />