multiple buttons on a form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    multiple buttons on a form

    The ASP page has multiple buttons, and when the user clicks different
    buttons, it will submit the form data to different URLs.

    My first approach was to use BUTTON type, and triggers javascript function
    to submit the form data. However, it didn't work properly and I changed to
    use SUBMIT type.

    <INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page"
    onClick="action 1()">

    function action1()
    { //etc...
    document.myform .action = "main.asp"
    document.myform .submit();
    }

    OR

    <INPUT TYPE="SUBMIT" NAME="action1" VALUE="Return to Main Search Page"
    onClick="action 1()">

    function action1()
    { //etc...
    document.myform .action = "main.asp"
    }

    So which is the appropriate way? please advise. thanks!!


  • PW

    #2
    Re: multiple buttons on a form


    "Matt" <mattloude@hotm ail.com> wrote in message
    news:%23nncuqwY EHA.3512@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > The ASP page has multiple buttons, and when the user clicks different
    > buttons, it will submit the form data to different URLs.[/color]


    When I need multiple buttons, I just have multiple forms as needed ...


    <form ID="myform2" NAME="myform2" method="GET" action="tran_sa le3.asp">
    <button onclick="submit ()" accesskey="P"
    style="width:25 0px;height:50px ;"><u>P</u>ROCEED</button>
    </form>
    <form ID="myform3" NAME="myform3" method="GET" action="tran_sa le9.asp">
    <button onclick="submit ()" accesskey="C"
    style="width:25 0px;height:50px ;"><u>C</u>ANCEL</button>
    </form>


    Comment

    • CJM

      #3
      Re: multiple buttons on a form

      Both the BUTTON and INPUT solutions will work, if you get your Javascript
      right.

      I tend to use <input type="submit"> because it has better browser support.

      e.g. <input type="submit" name="submit1"
      onclick="myform .action='main.a sp';">

      This is very similar to what you already have, so if there is still a
      problem it will be with the Javascript syntax - in which case repost your
      question to the .scripting.jscr ipt NG.

      hth

      Chris



      "Matt" <mattloude@hotm ail.com> wrote in message
      news:%23nncuqwY EHA.3512@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > The ASP page has multiple buttons, and when the user clicks different
      > buttons, it will submit the form data to different URLs.
      >
      > My first approach was to use BUTTON type, and triggers javascript function
      > to submit the form data. However, it didn't work properly and I changed to
      > use SUBMIT type.
      >
      > <INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page"
      > onClick="action 1()">
      >
      > function action1()
      > { //etc...
      > document.myform .action = "main.asp"
      > document.myform .submit();
      > }
      >
      > OR
      >
      > <INPUT TYPE="SUBMIT" NAME="action1" VALUE="Return to Main Search Page"
      > onClick="action 1()">
      >
      > function action1()
      > { //etc...
      > document.myform .action = "main.asp"
      > }
      >
      > So which is the appropriate way? please advise. thanks!!
      >
      >[/color]


      Comment

      Working...