4 Replies Latest reply: Jul 12, 2012 2:25 AM by Prodigy9 RSS

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

    Prodigy9 Community Member

      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" />

        • 1. Re: Trying to create two <form> buttons side by side?
          Ben Pleysier MVP

          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">



          • 2. Re: Trying to create two <form> buttons side by side?
            Prodigy9 Community Member

            Wow...  Thanks.  Just what I wanted it to do...  My question is appears to be Javascript...  What is actually happening with the function.  I am just learning PHP and JavaScript so I don't understand the function.



            Thanks A Lot!

            • 3. Re: Trying to create two <form> buttons side by side?
              Ben Pleysier MVP

              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.



              • 4. Re: Trying to create two <form> buttons side by side?
                Prodigy9 Community Member

                Hey Thanks Gramps...  I learned some new things which is always nice.


                I decided to remove the javascript code and use the:


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


                Just like you described.  I also learned a little bit more about using the tag inspector within CS6.


                I didn't know you could use the "onclick" function within a form field.  Are there any other functions I can use within html code?


                Also, is it compatible w/ most (if not all) browsers?  "onclick" is javascript right?