+ Reply to Thread
Results 1 to 1 of 1

Thread: Alert and Confirm boxes

  1. #1
    toxifyshadow's Avatar
    toxifyshadow is offline Programmer
    Join Date
    Mar 2010
    Location
    Oregon
    Posts
    125
    Blog Entries
    5
    Rep Power
    0

    Lightbulb Alert and Confirm boxes

    Sometimes you need to tell a user something and make sure the user sees it. That's when you use an alert box.
    Other times you need to make a user either confirm or decline something.That's when you could use a confirm box. Along with confirm boxes you could create a function to reply to what the user clicks on a comfirm box.That will be discribed at the end.

    For an alert box we simply use this:
    Code:
    alert("Here is the alert")
    Now to make that show up anywhere we create a function
    Code:
    function alert()
    {
    alert("Here is my alert")
    }
    and a button
    Code:
    <button type="button" onclick="alert()">Show Alert</button>
    So our full code is
    Code:
    <head><script type="text/javascript">
    function alert()
    {
    alert("Here is my alert")
    }
    </script></head><body><button type="button" onclick="alert()">Show Alert!</button></body>

    For a confirm box.
    Inside the head we do just about the same thing:
    Code:
    function confirm()
    {
    confirm("Are you serious?")
    }
    and in the body tag:
    Code:
    <button type="button" onclick="confirm()">Confirm this!</button>
    Using if
    Let's say you wanted something where if someone clicks yes, they get an alert that says something else. Do this with:
    Code:
    <head><script type="text/javascript">
    function cnfrm()
    {
    confirm("Are you serious?")
    if(r==true)
    {
    alert("Wow you are serious")
    }}
    </script></head><body><button type="button" onclick="cnfrm()">Confirm!</button></body>
    Did you single click or double click?

    Here we can create an alert that tells if you clicked once or twice:
    Code:
    <head><script type="text/javascript">
    function click()
    {
    alert("You clicked once")
    }
    function dblclick()
    {
    alert("You clicked twice")
    }
    </script>
    </head><body><button type="button" onclick="click()" ondblclick="dblclick()">Click 1 or 2 times</button></body>
    This is my second tutorial, Enjoy!
    Last edited by toxifyshadow; 03-30-2010 at 03:52 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Confirm Msn Account possibly breached
    By quantlinear in forum Computer Software/OS
    Replies: 2
    Last Post: 06-16-2011, 06:21 PM
  2. Spammer alert
    By Roger in forum Announcements
    Replies: 44
    Last Post: 10-09-2010, 05:49 AM
  3. Why do I keep getting an empty alert box?
    By system32 in forum JavaScript and CSS
    Replies: 7
    Last Post: 03-11-2010, 10:04 AM
  4. Replies: 4
    Last Post: 02-07-2010, 12:53 PM
  5. Confirm action
    By Jaan in forum JavaScript and CSS
    Replies: 9
    Last Post: 02-16-2009, 01:25 PM

Tags for this Thread

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