Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Javascript provides three different dialog components to perform the operation?

1 AlertBox:-  It is used to display a message to the user's

  alert("message")

2 Confirm:-  It is used to provide confirmation to user's and display ok and cancel button, it returns true in Ok and return false in cancel button

var s = confirm(message);
if(s)
{

}
else
{

}

3 Prompt:-  It is used to display Input dialog to user's as a textfield .it return value of textfield.

  var s = prompt("message")


Complete Code of Alert, Confirm Prompt:-

<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
function funalert()
{
            alert("Welcome in Alert");
}
function funconfirm()
{
          s= confirm("do you want to confirm to navigate");
          if(s)
          {
            // window.location= 'countrystatecity.html';
              window.location= "http://youtube.com/shivaconceptsolution";

          }
          else
          {
          alert("CANCEL");
          }
}
function funprompt()
{
           name = prompt("enter name");
           alert("name is "+name);
}

</script>

</head>
<body>
<button onclick="funalert()">ALERT</button>
<br>
<br>
<button onclick="funconfirm()">CONFIRM</button>
<br>
<br>
<button onclick="funprompt()">PROMPT</button>
<br>
</body>
</html>

                         

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post