Search This Blog

Tuesday 31 January 2017

Write a javascript program to demo alert box,conditional box and prompt box.

JS Prac 3

<html>
    <head>
    <title>Practicle 1 JS</title>
    <script>
        function myf(){
            alert("This is an alert box");
            }
           
        function mycon(){
            var x;
            if(confirm("Press Any")==true){
                alert("You Clicked Ok !");
            }else{
                alert("You Clicked Cancel !");
            }
        }
        function myprompt(){
            var name = prompt("Enter your name");
           
            if(name){
                alert("You Entered "+name);
            }else if(name==""){
                alert("msg empty");
            }else{
                alert("you canceled");
                }
        }
    </script>
    </head>
    <body>
    <button onclick="myf()">Alert</button><br/>
    <button onclick="mycon()">Confirm</button><br>
    <button onclick="myprompt()">Prompt</button>

    </body>
    </html>

1 comment: