SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Confirm alert issue

    How would I go checking if a certain submit button was pushed and if so
    confirm the user if he is sure.

    But if he pushes cancle, then it will cancle the operation.
    Danny Grubman @ http://www.our-network.net
    "Intellectuals solve problems; geniuses prevent them."

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    HTML Code:
      <input type="submit" name="submit" value="Go!" 
     onclick="return confirm('Are you sure you want to do this? I mean, you might not want to after all :)');" />
    Basically, once the user clicks on that submit button, he'll be asked to confirm whether he wants to continue or not with an "OK/Cancel" alert (known as a "confirm"). If he clicks OK the form submits as usual; if he clicks cancel, execution of the form stops.

  3. #3
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help m8.
    By the way, what about making the proccess stop after a certain alert?

    Here is an example:

    Lets say that an alert pops up and say that a certain function was desable and
    after the user clicks ok no proccess will take place.
    Danny Grubman @ http://www.our-network.net
    "Intellectuals solve problems; geniuses prevent them."

  4. #4
    SitePoint Enthusiast kidwizdumb's Avatar
    Join Date
    Oct 2003
    Location
    Ojai
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sleepingdanny
    By the way, what about making the proccess stop after a certain alert?
    Garcia's example implies this,

    It would be the return of the return...so to speak. If the function you call returns *false* and the onclick event also returns that value, which is false, then the form would not be submitted and you could display an alert box at the time it fails.

    The below code, would be inserted into the function you are calling:

    Code:
    alert("Alert User and Kill Form");
    return false;
    Hope this helps

  5. #5
    SitePoint Addict sleepingdanny's Avatar
    Join Date
    Oct 2002
    Location
    Israel
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exacly what I needed, thanks.
    Danny Grubman @ http://www.our-network.net
    "Intellectuals solve problems; geniuses prevent them."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •