0% found this document useful (0 votes)
4 views8 pages

Dialog Boxes of JavaScript

The document is an assignment on dialog boxes in JavaScript submitted by Anmol Rasheed for the Web Development course at Govt. Islamia Graduate College for Women. It explains three types of dialog boxes: Alert, Prompt, and Confirm, detailing their purposes, syntax, and providing example code. The assignment highlights how these dialog boxes interact with users to display information or gather input.

Uploaded by

anmolrasheed34gb
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Dialog Boxes of JavaScript

The document is an assignment on dialog boxes in JavaScript submitted by Anmol Rasheed for the Web Development course at Govt. Islamia Graduate College for Women. It explains three types of dialog boxes: Alert, Prompt, and Confirm, detailing their purposes, syntax, and providing example code. The assignment highlights how these dialog boxes interact with users to display information or gather input.

Uploaded by

anmolrasheed34gb
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Govt.

Islamia Graduate College for Women


on Eidgah Road, Faisalabad.

Academic Year 2022-2026


Department of Computer Science

Assignment: Dialog Boxes in JavaScript

Full Name: Anmol Rasheed

Roll No: 103722(19) Section: Morning

Subject: Web Development Date of Submission: 01-02-2025

Student Name: Anmol Submitted to: Mam Zahra

1
Assignment
Dialog Boxes In JavaScript:
Dialog boxes are used to interact with the user. Some
dialog boxes are used to get input from the user and
to display information to the user.

Some important dialogue boxes in JavaScript are as follows:


1. Alert Dialog Box
2. Prompt Dialog Box
3. Confirm Dialog Box

1. Alert Dialog Boxes:


The alert box is used to display information to the user. It
takes a string parameters and display it in a dialog box. The dialog
box contains OK button. The user has to press OK button to close it.

Syntax:
alert (“Message”);

CODE:

<script>

alert(“Welcome to JavaScript”);

</script>

Coding on Visual Studio Code:

2
Output:

3
2. Prompt Dialog Box:

Prompt dialog box is used to get input from the user.


The input given by the user in prompt dialog box can be stored in a variable
for further processing. Prompt dialog box displays the following:

 A new messages to the user that tells the user to input a value.
 A textbox where the user types the input.

The OK and Cancel buttons.

Syntax:

Prompt(“Message”,”Defualtvalue”);

CODE:

<script>

var n;

n=prompt(“Enter your name:”,”Name”);

[Link](“Hello <B>” +n +”!</B>Welcome to JavaScript..”);

</script>

4
Coding on Visual Studio Code

Output:

5
3. Confirm Dialog Box:

The confirm dialog box is used to confirm the


action of the user. It contains the following:

 A message to the user.


 The OK and Cancel buttons.

If the user clicks OK button, a True value is passed to JavaScript


code If the user clicks Cancel button, a False value is passed to
JavaScript code.

Syntax:
confirm(“Message”);

CODE:
<script>

var r;
n =confirm(“Click any button:”);

if(n==true)

[Link](“You clicked OK.”);


6
else

[Link](“You clicked Cancel.”);

</script>

Coding on Visual Studio Code:

7
Output:

You might also like