Java Script


JavaScript Tutorial


Admission Enquiry Form

alert() prompt() confirm() and parseInt() methods in JavaScript

alert() method in JavaScript

alert() method is used to display a message in the box

alert("Welcome to Compuhelp");





prompt() method in JavaScript

The prompt method in JavaScript is used to take input from the user

var name=prompt("Enter your name:");
document.write(name);





confirm() method in JavaScript

The confirm() method displays a dialog box with a specified message, along with an OK and a Cancel button.

A confirm box is used if you want the user to verify or accept something.

confirm("Are you sure you want to exit?");




parseInt() method in JavaScript

In JavaScript prompt always take the input in the form of string.To convert it into integer we use parseInt() method.

var num1=parseInt(prompt("Enter a number"));
var num2=parseInt(prompt("Enter second number"));
res=num1+num2;
document.write(res);