onclick together with input type =submit

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

    #1

    onclick together with input type =submit

    hi,

    I've got a submit button, and when one clicks it, I want a confirm box
    to pop up to make sure the user really wants that. The user is
    supposed to be redirected to another url if he presses OK, and do
    nothing if not. The way it works at the moment, is that the confirmbox
    appears as it should, but whatever the user presses, the php code
    continues to run. Any suggestions?

    php:

    echo "<INPUT type =\"submit\" name =\"test\"
    ONCLICK=\"decis ion('sure?')\" value =\"Slett messe!\">
    </TD></TR></form></table><br>";
    function decision(messag e){
    if (confirm(messag e)) window.location .href='http://www.vg.no';
    }

    obscurr
  • Daniel

    #2
    Re: onclick together with input type =submit


    "Obscurr" <obscurr@hotmai l.com> wrote in message
    news:4452c409.0 307030358.228d2 071@posting.goo gle.com...[color=blue]
    > hi,
    >
    > I've got a submit button, and when one clicks it, I want a confirm box
    > to pop up to make sure the user really wants that. The user is
    > supposed to be redirected to another url if he presses OK, and do
    > nothing if not. The way it works at the moment, is that the confirmbox
    > appears as it should, but whatever the user presses, the php code
    > continues to run. Any suggestions?
    >[/color]

    You could replace the "submit" button with a "button" button and put

    onClick="if (confirm('Reall y submit?')) { this.form.submi t(); }"

    that might work?


    Comment

    • Daniel

      #3
      Re: onclick together with input type =submit


      "Obscurr" <obscurr@hotmai l.com> wrote in message
      news:4452c409.0 307030358.228d2 071@posting.goo gle.com...[color=blue]
      > hi,
      >
      > I've got a submit button, and when one clicks it, I want a confirm box
      > to pop up to make sure the user really wants that. The user is
      > supposed to be redirected to another url if he presses OK, and do
      > nothing if not. The way it works at the moment, is that the confirmbox
      > appears as it should, but whatever the user presses, the php code
      > continues to run. Any suggestions?
      >[/color]

      You could replace the "submit" button with a "button" button and put

      onClick="if (confirm('Reall y submit?')) { this.form.submi t(); }"

      that might work?


      Comment

      • Martin Honnen

        #4
        Re: onclick together with input type =submit



        Obscurr wrote:[color=blue]
        > hi,
        >
        > I've got a submit button, and when one clicks it, I want a confirm box
        > to pop up to make sure the user really wants that. The user is
        > supposed to be redirected to another url if he presses OK, and do
        > nothing if not. The way it works at the moment, is that the confirmbox
        > appears as it should, but whatever the user presses, the php code
        > continues to run. Any suggestions?
        >
        > php:
        >
        > echo "<INPUT type =\"submit\" name =\"test\"
        > ONCLICK=\"decis ion('sure?')\" value =\"Slett messe!\">
        > </TD></TR></form></table><br>";
        > function decision(messag e){
        > if (confirm(messag e)) window.location .href='http://www.vg.no';
        > }
        >[/color]

        If you want to submit a form use
        <form action="whateve r.php" ...>
        ...
        <input type="submit"
        onclick="return confirm('Are you sure you want to submit the
        form?');">



        --

        Martin Honnen
        http://JavaScript.FAQTs.com/

        Comment

        Working...