| Categories | Latest | Search | Login |

Back

Simple Popup Dialogues



Here's simple way to display a message using an alert dialogue from a function:


<script type="text/javascript">

function do_popup()
{
   alert("Hello, i'm a simple alert!");
}

</script>

<a onclick="do_popup()" href='#'>Push Me</a><br>



You can do it just easily from inside a tag:

<a onclick="alert('Hi');" href='#'>Push Me</a><br>





Confirm Dialogue

An easy 'OK' or 'Cancel' response can be aquired using this dialogue box and used to confirm an action. If 'OK' is selected then true is returned, else false is returned.

<script type="text/javascript">

function do_confirm()
{
   var s = confirm("Are you sure?");
   alert(s);
}

</script>

<a onclick="do_confirm()" href='#'>Push Me</a><br>



Promt Dialogue

There is a prompt dialogue which can be used to ask for user input. The first parameter is the displayed text, whilst the second parameter is the default answer, leave this empty if there is no default answer.

<script type="text/javascript">

function do_prompt()
{
   var s = prompt("Is this your name?", "Gilburt");
   alert(s);
}

</script>

<a onclick="do_prompt()" href='#'>Push Me</a><br>




Back

rabbit By rabbit Created on 18th of April 2010, at 10.53 pm
Modified on 21st of June 2010, at 8.25 pm
Category: Javascript: General

rabbitin on again!

Other Docs by rabbit

   system and popen
   Ticker Tape Scrollers
   Javascript Regular Expressions
   Simple Popup Dialogues
   Matrix

View all



Digg  del.icio.us  Reddit  Slashdot  StumbleUpon  TwitThis  


COMMENTS


Search Docs


Browse Docs

Programming
     C
     C++
     Python
     Tcl/Tk
     Java
     PHP
     Perl
     HTML
     Javascript
     Other
Computing
     Linux
     Windows
     Security
     Networks
     Graphics
     Gaming
     Other