Saturday, 14 September 2024

WRITE A JAVASCRIPT TO DISPLAY WEEKDAY USING PROMPT

 

CODE :-

<html>

                <head>               

                                <title>Weekday</title>

                                <script type="text/javascript">

                                                function check()

                                                {

                                                                var no=parseInt(prompt("Enter Number="));

                                                               

                                                                if(no==1)

                                                                {

                                                                                document.write("Monday");

                                                                }

                                                                else if(no==2)

                                                                {

                                                                                document.write("Tuesday");

                                                                }

                                                                else if(no==3)

                                                                {

                                                                                document.write("Wednesday");

                                                                }

                                                                else if(no==4)

                                                                {

                                                                                document.write("Thursday");

                                                                }

                                                                else if(no==5)

                                                                {

                                                                                document.write("Friday");

                                                                }

                                                                else if(no==6)

                                                                {

                                                                                document.write("Saturday");

                                                                }

                                                                else if(no==7)

                                                                {

                                                                                document.write("Sunday");

                                                                }

                                                                else

                                                                {

                                                                                document.write("Invalid Choice");

                                                                }

                                                }

                                </script>

                                </head>

                                <body>

                                                <form name="form1" method="post" onsubmit="return check()">

                                                                <input type="submit" name="submit" value="Submit">

                                                </form>

                                </body>

</html>

No comments:

Post a Comment