Popup Boxes in JavaScript
Hello, I am learning java script. Recently I had read the pop box examples in java script from my book. But, I am not able to get the exact idea about it. If anyone is having details about it, then please provide me that. Please provide me some scripts if you have. So, that I can able to get idea about the use of it.
Re: Popup Boxes in JavaScript
JavaScript Provides you three types of Popup Box:
- Alert box
- Confirm box
- Prompt box
Alert box : Aletbox is quiet similar with the message box in the vb script. It will be used to make sure for getting input from the user. It also provide the OK button for further continue.
Confirm Box : This Box contains the Ok and Cancel button. If use clicks on the cancel the box will return the false value. If user clicks on the Ok then true value is returned.
Prompt Box : This box contains the OK and cancel button. If user is inputting the value then you can provide this box to user.
Re: Popup Boxes in JavaScript
JavaScript provides following types of Popup Boxes:
1)Alert Box: This is just for surarity of input.
Syntax:
Code:
alert("Add text Here");
2)Confirm Box: It will verify or get some input.
Syntax:
Code:
confirm("Add text Here");
3)Prompt Box: This is used to input value before page submission.
Syntax:
Code:
prompt("Add text Here","By Deault Value");
Re: Popup Boxes in JavaScript
It can be possible to use the three different types of Popup boxes withe the help of java script:
ALERT BOX :
- When user click on OK, he can go further.
- Mostly used to make sure that the input is provided by the user or not.
- It can be used to provide the warning message.
CONFIRM BOX:
- When user click on OK or Cancel, he can perform further task.
- Mostly used to verify the input from the user.
- It will ask you further processing cab be done or not.
PROMPT BOX:
- When user click on OK or Cancel, he can perform further task.
- Mostly used to provide information to the user.
Re: Popup Boxes in JavaScript
If you are using Java Script then it may provide you three types of Pop Boxes as below:
- Alert box :alert("Message");
- Confirm box :confirm("Message");
- Prompt box :prompt("Message","Deault Value");
Re: Popup Boxes in JavaScript
Popbox script:
Alert Box:
Code:
<html>
<head>
<script type="text/javascript">
function alertexample()
{
alert("Got the message");
}
</script>
</head>
<body>
<input type="button" onclick="alertexample()" value="Show alert box" />
</body>
</html>
Confirm Box:
Code:
<html>
<head>
<script type="text/javascript">
function confirmexample()
{
var check=confirm("Press ");
if (check==true)
{
document.write("Ok pressed!");
}
else
{
document.write("Cancel pressed ");
}
}
</script>
</head>
<body>
<input type="button" onclick="confirmexample()" value="Show confirm box" />
</body>
</html>
Prompt Box:
Code:
<html>
<head>
<script type="text/javascript">
function promptexample()
{
var msg=prompt("Message");
if (msg!=null && msg!="")
{
document.write("Got message");
}
}
</script>
</head>
<body>
<input type="button" onclick="promptexample()" value="Show prompt box" />
</body>
</html>