JavaScript with HTML Part – 2

Full Stack Web Development Courses with Real-time projects Start Now!!

Program 1

<html>
    <head>
        <title>This is My Java Script Event Page</title>
        <script type="text/javascript">
            function message()  // Defination
            {
                 alert("This is my click button")
                 let i
                 for(i=1;i<=10;i++)
                 {
                    document.writeln(i + "<br>")
                 }
             }
             function display()  // Defination
            {
                 alert("This is my display code")
             }
         </script>
    </head>
    <body onload="display()">
        <center>
            <h1>Wel Come in Java Script Event Page</h1>
            <form>
                <input type="button" value="Click Here"  ondblclick="message()">
             </form>   
         </center>   
    
    </body>
</html>

Program 2

<html>
    <head>
        <title>This is My Java Script Event Page</title>
        <script type="text/javascript">
            function message()  // Defination
            {
                  let n,f=1
                  n=parseInt(document.getElementById("TXTID").value)
                 while(n!=0)
                 {
                      f=f*n
                      n--
                 }
                document.writeln("<font color=green size=5>Factorial is: "+ f + "</font>")
             }
            
         </script>
    </head>
    <body>
        <center>
            <h1>Wel Come in Java Script Event Page</h1>
            <form>
                  Enter A Number:<input type=text name="txtno" id="TXTID">
                  <input type="button" value="Factorial" onclick="message()">
             </form>   
         </center>   
    
    </body>
</html>

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *