Posts

Showing posts from April, 2022

FY B.sc IT Practical 3(E) : Write a program in JavaScript to accept a sentence from the user and display the number of words in it. (Do not use split () function).

 <!DOCTYPE html> <html> <head> <title>Without using split function</title> <script> var str=prompt("Enter the sentence=",""); var count=0; for(i=0;i<str.length;i++) { if(str.charAt(i,1)==" " && str.charAt(i+1,1)!=" ") count++; } document.write("Number of words are="+(count+1)); </script> </head> <body> </body> </html>

FY B.sc IT Practical 3(D) : Write a JavaScript program to accept a number from the user and display the sum of its digits.

 <!DOCTYPE html> <html> <head> <title>sum of digits</title> <script> var n=parseInt(prompt("Enter the number"," ")); var p=0,y; while(n>0) { y=n%10; n=parseInt(n/10); p=p+y; } document.write("Sum of digits is: "+p); </script> </head> </html>

FY B.sc IT Practical 3(C) : Write a JavaScript program to display all the prime numbers between 1 and 100.

 <!DOCTYPE html> <html> <head> <title>prime number</title> <script> for(var i=1;i<=100;i++) { var flag=0; for(var j=2;j<=i/2;j++) { if(i%j==0) { flag=1; break; } } if(flag==0) { document.write(i+"<br>"); } } </script> </head> </html>

FY B.sc IT Practical 3(B) : Design a form and validate all the controls placed on the form using Java Script.

 <html> <head> <title>Form Validation</title>  <script type="text/javascript"> function validate()  { if( document.myForm.Name.value == "" )  {  alert( "Please provide your name!" );  document.myForm.Name.focus();  return false; } if( document.myForm.EMail.value == "" )  {  alert( "Please provide your Email!" );  document.myForm.EMail.focus();  return false;  }    if( document.myForm.Zip.value == "" ||isNaN(  document.myForm.Zip.value ) ||  document.myForm.Zip.value.length != 5 )  {  alert( "Please provide a zip in the format #####." );  document.myForm.Zip.focus();  return false;  } if( document.myForm.Country.value == "-1" )  {  alert( "Please provide your country!" );  return false;  }  return(true);  }  </script> </head> <body> <form name="myForm" onsubmit="return(validate());"> <table cel...

FY B.sc IT Practical 3(A) : Using JavaScript design, a web page that prints factorial/Fibonacci series/any given series.

i) Factorial: <!DOCTYPE html> <html> <head> <title>Factorial Demo</title> <script language="javascript"> var x=parseInt(prompt("Enter a number","")); var fact=1,i; for(i=1;i<=x;i++) fact*=i; document.write("<h1>Factorial of "+x+" is : "+fact+"</h1>"); </script> </head> <body> </body> </html> ii) Fibonacci: <!DOCTYPE html> <html> <head> <title>Fibonacci series Demo</title> <script language="javascript"> var a=0,b=1,c,n,i; n=parseInt(prompt("Enter limit for fibonacci series:","")); document.write("<h2> Fibonacci series: </h2><br>"); document.write(a+" "+b+" ");  for(i=2;i<n;i++) { c=a+b; document.write(c+" "); a=b; b=c; } </script> </head> <body> </body> </html>

FY B.sc IT Practical 2(E): Design a web page embedding with multimedia features.

Note: Download  'Video' and 'Audio' files and keep it in the same folder where the program is been saved.   <!DOCTYPE html> <html> <head> <title>Multimedia</title> </head> <body> Video File: <video width="240" height="320" controls> <source src="myvideo.ogv" type="video/ogg"> <source src="myvideo.mp4" type="video/mp4"> <source src="myvideo.avi" type="video/avi"> <embed src="myvideo.mp4"> </video> <br> Audio File: <audio width="240" height="320" controls> <source src="myaudio.ogv"> <source src="myaudio.mp4"> <source src="myaudio.avi"> <embed src="myaudio.mp4"> </audio> </body> </html>