Skip navigation
Currently Being Moderated

Trying to create two <form> buttons side by side?

Jul 11, 2012 6:20 PM

Hi all...


Kind of a strange question...  I've been messing around with this one for way too long now and thought I'd seek your help...


Anyway,  one <form> with two submit buttons on them.  One is a "submit" button and the other is a "cancel" button.  I do have them working fine.  The "submit" button forwards the <form> data to the .php file for processing (and works fine).  However, the cancel button which does nothing more than calls on the index.html.


Problem:  I can't get them to sit side by side on the form...  Or at least not without making the "cancel" button fail.  Remember this is all one form (or is it?)...


The last lines of code for the "submit or cancel" buttons are below...


<form action="contactlist.php" method="post" name="contactform" >  <----  This is the first line for the actual form.  The remaining code is for the buttons at the bottom of the form.



<input name="submit" type="submit" value="submit"/>



<form action="index.html" method="post" name="contactform"/>

<input name="cancel" type="submit" value="cancel" />

  • Currently Being Moderated
    Jul 11, 2012 10:15 PM   in reply to Prodigy9

    These are two forms, assuming that you do have and end form tag for the second form.


    If you wnat the cancel button to return to the home page, try the following

    <!doctype html>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    <form action="contactlist.php" method="post" name="contactform" >
    <input name="submit" type="submit" value="submit">
    <input name="cancel" type="button" value="cancel" onClick="MM_goToURL('parent','index.html');return document.MM_returnValue">



    Mark as:
  • Currently Being Moderated
    Jul 11, 2012 11:53 PM   in reply to Prodigy9

    If you are learning, I would not worry too much about JavaScript, just concentrate on PHP.


    Normally I would use

    <input name="cancel" type="button" value="cancel" onclick="window.location='index.html'">

    which simply saying that when the element (<input>) is clicked on, change the URL to 'index.htm'.


    The reason I used the function in my first example, is because DW supplies the function auromatically by following this procedure


    1. In design view, click the cancel button. In code view you will see the element highlighted and the status bar will show <input> highlighted as in


    Also in the properties window under the status bar, you will be able to change the button attributes.


    2. With the button highlighted, click on the Tag Inspector-->Behaviours tab, click the '+' and 'Go to URL' as follows


    This will pop-up a dialog.


    3. In the 'Go To URL' dialog leave the 'Open in' field with the default value and enter the requested URL in the 'URL' field, using the browse feature if desired.



    4. Click 'OK' and in the code view you will see the added JS function and the behaviour attached to the button. In the Behaviours panel you will also see the behaviour attched to the selected element.



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points