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

Thanks

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

if($_POST[‘delete’]){

}

if($_POST[‘save’]){

}

etc

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.

<?php
if (isset($_POST['btnSubmit'][0])) {
    switch (strtolower($_POST['btnSubmit'][0])) {
        case 'save':
            echo '<h1>Save button was clicked</h1>';
            break;
        case 'delete':
            echo '<h1>Delete button was clicked</h1>';
    }
    die();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title></title>
    </head>
    <body>
        <form action="#" method="post">
            <input type="submit" name="btnSubmit[]" value="Save" />
            <input type="submit" name="btnSubmit[]" value="Delete" />
        </form>
    </body>
</html>