Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: PROMPT button

  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question PROMPT button

    How to use cancel and ok buttons of prompt inorder to trigger some event in response to them?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You shouldn't really be using prompt at all as it can have more than two options show up as it is intended for use as a debugging tool.

    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by iBall View Post
    If you are including me then I disagree because ...
    I was directing that at everyone but since you mention it I specifically disagree with letting any intermediate and beginner JavaScript programmers know that prompt() even exists because it creates bad habits and they really ought to be using a simple form in their page to collect the information (which is no harder to code and a lot more useful for them to know).

    Anywhere that beginners are using prompt() they should be using <form>

    prompt was only easier back when document.write was used instead of innerHTML and so you couldn't actually display anything in the actual web page.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,632
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by iBall View Post
    that's ok. I'm the opposite and so we'll just have to disagree on this one because I will continue to tell beginners on the websites I post on that using document.write is ok under the conditions I posted earlier
    One day you will wake up and discover that the 20th Century is over. Until that day comes - perhaps in a few hundred year's time - I am sure that we can quite happily continue to disagree.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,924
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by iBall View Post
    I knew it was over when I woke up on the morning of Jan 1, 2001 with a very sore head .
    And still got it, it seems. Is that why you behave like a bear with a sore head? Always in a bad mood which causes you to treat other people badly and complain a lot?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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