Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
76 views

Alert Dialog Box

JavaScript is a lightweight programming language used to build interactive effects into web pages. It is designed for client-side scripting, is implemented as part of web browsers, and is used to develop dynamic web page content. JavaScript code can easily be added to HTML pages and is commonly used to validate forms, detect browser capabilities, and add interactive elements like menus.

Uploaded by

Abhi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Alert Dialog Box

JavaScript is a lightweight programming language used to build interactive effects into web pages. It is designed for client-side scripting, is implemented as part of web browsers, and is used to develop dynamic web page content. JavaScript code can easily be added to HTML pages and is commonly used to validate forms, detect browser capabilities, and add interactive elements like menus.

Uploaded by

Abhi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JavaScript is a lightweight, interpreted programming language.

It is designed for creating


network-centric applications. It is complimentary to and integrated with Java. JavaScript is
very easy to implement because it is integrated with HTML. It is open and cross-platform.

<html>
<body>
<script language = "javascript" type = "text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
</body>
</html>

Alert Dialog Box


An alert dialog box is mostly used to give a warning message to the users. For
example, if one input field requires to enter some text but the user does not provide
any input, then as a part of validation, you can use an alert box to give a warning
message.
Nonetheless, an alert box can still be used for friendlier messages. Alert box gives
only one button "OK" to select and proceed.

Example

<html>
<head>
<script type = "text/javascript">
<!--
function Warn() {
alert ("This is a warning message!");
document.write ("This is a warning message!");
}
//-->
</script>
</head>

<body>
<p>Click the following button to see the result: </p>
<form>
<input type = "button" value = "Click Me" onclick =
"Warn();" />
</form>
</body>
</html>

Confirmation Dialog Box


A confirmation dialog box is mostly used to take user's consent on any option. It
displays a dialog box with two buttons: OK and Cancel.
If the user clicks on the OK button, the window method confirm() will return true. If
the user clicks on the Cancel button, then confirm() returns false. You can use a
confirmation dialog box as follows.

Example

<html>
<head>
<script type = "text/javascript">
<!--
function getConfirmation() {
var retVal = confirm("Do you want to continue ?");
if( retVal == true ) {
document.write ("User wants to continue!");
return true;
} else {
document.write ("User does not want to
continue!");
return false;
}
}
//-->
</script>
</head>

<body>
<p>Click the following button to see the result: </p>
<form>
<input type = "button" value = "Click Me" onclick =
"getConfirmation();" />
</form>
</body>
</html>

Prompt Dialog Box


The prompt dialog box is very useful when you want to pop-up a text box to get user
input. Thus, it enables you to interact with the user. The user needs to fill in the field
and then click OK.
<html>
<head>
<script type = "text/javascript">
<!--
function getValue() {
var retVal = prompt("Enter your name : ", "your
name here");
document.write("You have entered : " + retVal);
}
//-->
</script>
</head>

<body>
<p>Click the following button to see the result: </p>
<form>
<input type = "button" value = "Click Me" onclick =
"getValue();" />
</form>
</body>
</html>

You might also like