ADVANCED JAVASCRIPT

7 Differnt Background Color

<!DOCTYPE html>

<html>

  <head><title>Backgroung color javascript program</title>

   <script type="text/javascript">

     function fun1()

        {

          document.bgColor="blue";

  window.setTimeout("fun2()",2000);

}

function fun2()

        {

          document.bgColor="yellow";

  window.setTimeout("fun3()",2000);

}

function fun3()

        {

          document.bgColor="red";

  window.setTimeout("fun4()",2000);

}

function fun4()

        {

          document.bgColor="green";

  window.setTimeout("fun5()",2000);

}

function fun5()

        {

          document.bgColor="orange";

  window.setTimeout("fun6()",2000);

}

function fun6()

        {

          document.bgColor="pink";

  window.setTimeout("fun7()",2000);

}

function fun7()

        {

          document.bgColor="violet";

  window.setTimeout("fun1()",2000);

}

function funmsg()

        {

            window.status("Display of seven different colors");

}

    </script>

  </head>

  <body>

    <h1> 7 different colors</h1>

 <form>

   <input type="button" Value="change color" name="btnchange" onmouseover="fun1()">

   <input type="button" value="changestatus" name="btnmsg" onClick="funmsg()">

 </form>

  </body>

</html>


<!DOCTYPE html>

<html>

  <head><title>Backgroung color change when page is loaded javascript program</title>

   <script type="text/javascript">

     function fun1()

        {

          document.bgColor="blue";

  window.setTimeout("fun2()",2000);

}

function fun2()

        {

          document.bgColor="yellow";

  window.setTimeout("fun3()",2000);

}

function fun3()

        {

          document.bgColor="red";

  window.setTimeout("fun4()",2000);

}

function fun4()

        {

          document.bgColor="green";

  window.setTimeout("fun5()",2000);

}

function fun5()

        {

          document.bgColor="orange";

  window.setTimeout("fun6()",2000);

}

function fun6()

        {

          document.bgColor="pink";

  window.setTimeout("fun7()",2000);

}

function fun7()

        {

          document.bgColor="violet";

  window.setTimeout("fun1()",2000);

}

function msg()

{

alert("Display 7 different color");

}

    </script>

  </head>

  <body onload="fun1()" onunload="msg()">

     </body>

</html>




Vowels.html  Count Vowels

<!DOCTYPE html>

  <head><title> Count Vowels</title>

   <script type="text/javascript">

      function count()

       {

    var i,ch,str,count=0;

   str=form1.t1.value;

            for(i=0;i<str.length;i++)

              {

ch=str.charAt(i);


                if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||ch=='U'||ch=='u')

                  count++;

      }

                    alert("Number of Vowels in string :"+count);

}

  

    </script> 

   </head>

   <body>

   <form name="form1">

        <h1>Enter the String</h1>

        <input type="text" name="t1">

        <input type="button" name="btnsubmit" value="Click to Count" onClick="count()">

     </form>

</body>

</html>

TO CHECK GIVEN STRING IS PALANDROM STRING OR NOT


<!DOCTYPE html>

<html>

 <head><title>TO CHECK GIVEN STRING IS PALANDROM STRING OR NOT</title>

<script type="text/javascript">

function display()

{

     var a,s,i,ch,n,p=1;

     a=document.f1.t1.value;

     s=a.toLowerCase();

     n=s.length;

     for(i=0;i<n/2;i++)

       {

            if(s.charAt(i)!=s.charAt(n-1-i))

            {

              p=0;

              break;

           }

       }

    if(p==1)

      {

       alert("string is palindrome");

      }

      else

      {

       alert("string is not  palindrome");

      }

}

</script>

</head>

<body>

<h1 align="Center">TO CHECK GIVEN STRING IS PALANDROM  OR NOT</h1>

<form name="f1">

Enter String: <input type="text" name="t1"><br>

<input type="button" value="Palandrom String" onClick="display()">

</form>

</body>

</html>


<!DOCTYPE html>

<html>

 <head><title>Average Marks</title>

<script type="text/javascript">

function display()

{

  var s1,s2,s3,s4,s5,s6,tot,avg;

  s1=parseInt(f1.txteng.value);

  s2=parseInt(f1.txtphy.value);

  s3=parseInt(f1.txtche.value);

  s4=parseInt(f1.txtbio.value);

  s5=parseInt(f1.txtmath.value);

  s6=parseInt(f1.txtit.value);

   tot=s1+s2+s3+s4+s5+s6;

   avg=tot/6;

 alert("Average Marks of students is:"+avg);

 if(avg>=91 && avg<=100)

   {

      alert("GRADE IS A");

   }

  

  else if(avg>=81 && avg<=90)

   {

      alert("GRADE IS B");

   }

  if(avg>=71 && avg<=80)

   {

     alert("GRADE IS C");

   }

   if(avg>=61 && avg<=70)

   {

     alert("GRADE IS D");

  }

  else if(avg>=35 && avg<=60)

  {

  alert("GRADE IS F");  

  }

  else

  {

     alert("Invalid Grade"); 

  }

}

</script>

</head>

<body>

<h1 align="Center">TO COMPUTE AVERAGE MARKS OF STUDENTS</h1>

<form name="f1">

Enter English Marks: <input type="number" name="txteng"><br>

Enter Physics Marks: <input type="number" name="txtphy"><br>

Enter Chemistry Marks: <input type="number" name="txtche"><br>

Enter Biology Marks: <input type="number" name="txtbio"><br>

Enter Math Marks: <input type="number" name="txtmath"><br>

Enter IT Marks: <input type="number" name="txtit"><br>

<input type="button" value="AVERAGE MARKS" onClick="display()">

</form>

</body>

</html>


Comments

Popular posts from this blog

HSC BOARD ONLINE EXAM 25 HTML AND JAVASCRIPT PROGRAM LIST

HTML AND JAVASCRIPT PROGRAM

H.S.C INFORMATION TECHNOLOGY Q.8 HTML AND JAVASCRIPT PROGRAM