Friday, 13 September 2024

WRITE A JAVASCRIPT TO CHECK MAXIMUM NUMBER FROM TWO NUMBER USING USER INPUT

 

 

CODE :-

<html>

               <head>

                              <title>Max</title>

                              <style type="text/css">

                                             body{

                                                                           background-color:lightblue;

                                             }

                                             .tab{

                                                                           background-color:lightgrey;

                                             }

                                             .v1{

                                                                           text-align:center;

                                                                           background-color:lightyellow;

                                             }

                                             .v2{

                                                                           background-color:lightyellow;

                                             }

                              </style>

                              <script type="text/javascript">

                                             function check()

                                             {

                                                            var a,b;

                                                           

                                                            a=parseInt(document.form1.no1.value);

                                                            b=parseInt(document.form1.no2.value);

                                                           

                                                            if(a>b)

                                                            {

                                                                           document.form1.ans.value=a;

                                                            }

                                                            else

                                                            {

                                                                           document.form1.ans.value=b;

                                                            }

                                                            return false;

                                             }

                              </script>

               </head>

               <body> 

                              <center>

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

                                             <table border="1" cellspacing="0" class="tab">

                                                            <tr class="v2">

                                                                           <th colspan="2">To Check Maximum Number.</th>

                                                            </tr>

                                                            <tr>

                                                                           <th>Enter Number 1:</th>

                                                                           <td><input type="text" name="no1" size="5" style="border-radius:15px;"></td>

                                                            </tr>

                                                            <tr>

                                                                           <th>Enter Number 2:</th>

                                                                           <td><input type="text" name="no2" size="5" style="border-radius:15px;"></td>

                                                            </tr>

                                                            <tr class="v1">

                                                                           <td colspan="2">

                                                                                          <input type="submit" name="submit" value="Submit" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

                                                                                          <input type="reset" name="reset" value="Reset" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

                                                                           </td>

                                                            </tr>

                                                            <tr>

                                                                           <th>Max Number Is:</th>

                                                                           <td><input type="text" name="ans" size="5" style="border-radius:15px;"></td>

                                                            </tr>

                                             </table>

                              </form>

                              </center>

               </body>

</html>

No comments:

Post a Comment