Sunday 10 January 2021

JavaScript Dialog Boxes

 JAVASCRIPT DIALOGBOX

There are three types of Dialog Boxes are available in java Script

- Alert()

- Confirm()

- Prompt()

___________________________________________________________

alert() : An alert box is used if you want to sure information comes through to the user.

Example 1:

<script>

document.write("Dialog Boxes");

alert("Welcome to My BOX");

</script>


Example 2: Addition

<script>

a = 10;

b= 20;

c = a+b;


document.write(c);

alert("Addition is : "+c);


</script>


Example 3: alert with Button

<input type=button value="Click Me" onclick="alert(' Welcome to JavaScript')"> 

<br><br>


<input type=button value="Register" onclick="alert(' Welcome to MY Alert BOX')"> 

<br><br>


<input type=button value="HI Friends" onclick="alert(' This is Scripting Language')"> 

<br><br>


__________________________________________________

Confirm(): A confirm box is often used if you want the user to verify or accept something. confirm box provide two buttons OK and Cancel

Example:

<script>

alert("Thanks for Visit My WebSite");

confirm("Are Your Sure to Delete ....");

</script>

______________________________________________________

Prompt(): A prompt box is often used if you want the user to input a value before entering a page. prompt box provide input box with OK and cancel button when click on OK then return return if you click on cancel button then return false

Example 1: 

<script>

//getiing a values from the user using Prompt Box

prompt("Enter NO");

</script>


Example 2: 

<script>

i = prompt("Enter Your Name");

document.write("Your Name is :"+i);

</script>


Example 3:

<script>

//prompt getting a by default values are string


//Converting a String to Integer using parseInt() 


a= parseInt(prompt("Enter No")); 

b = parseInt(prompt("Enter No2")); 

c = a+b; 

document.write("Addition is : "+c);

</script>








1 comment: