Mmlab
Mmlab
LAB-MANUAL
3.Write a JAVASCRIPT Program to determine whether the given year is a leapyear in the
Gregorian Calendar
<html>
<head>
<title> Leap year </title><script> function leapyear()
{
var x;
x = document.getElementById("demo").value; if( (x % 4==0) && ( x % 100!=0) || ( x %
400==0) )
{
alert(x+" is a leap year");
}
else
{
alert(x+" is not a leap year");
}
}
</script>
</head>
<body>
<h2>Javascript Program to find leap year</h2>
<input type="text" id="demo"></input>
<button onclick="leapyear()">Check</button>
</body>
</html>
OUTPUT:
</script>
</head>
<body>
<p><label> Fahrenheit </label>
<input Id=”Faherenheit”type="number" placeholder="Fahrenheit"
oninput="TC(this.value)"onchange="TC(this.value)"></p>
<p> Celsius: <span id="outputCelsius"></span></p>
<p><label> Celsius </label>
<input id="Celsius" type="number" placeholder="Celsius"
Oninput=TC1(this.value)"onchange="TC1(this.value)"></p><p> Fahrenheit: <span
id="outputFahrenheit"></span></p></body>
</html>
OUTPUT:
<!DOCTYPE HTML>
<html>
<head>
<title>Animation</title>
<link href=”ss.css” rel=”stylesheet” type=”text/css”>
</head>
<body>
<div id=”change”>
</div>
</body>
</html>
#change
{
Width:100px;
Height:100px;
Border:2px solid black; -webkit-animation:changeColor 8s infinite;
}
@-webkit-keyframes changeColor
{
0%{background-color:blue;}
25%{background-color:yellow;}
50%{background-color:green;}
75%{background-color:red;}
100%{background-color:black;}
}
OUTPUT:
<p>Footer</p>
</footer>
</body>
<style>
*{
box-sizing: border-box;
}
header { background-color: lightblue; text-align: center; padding: 2px; font-size:
25px; color:white;
} nav { float: left; width: 30%; height: 300px; background: #fff; padding: 20px;
}
navul { list-style -type: none; padding: 0; }
article { float: left; padding: 20px; width: 70%; background-color:
#f1f1f1; height: 300px;
}
footer { background-color: lightblue; padding: 10px; text-align: center; color:
white;
}
section::after {
content: ""; display: table; clear: both;
}
</style>
</body>
Page
</html>
OUTPUT:
7. Write a JavaScript that calculates the squares & cubes of the numbers from 0 to 10
and outputs HTML text that displays the resulting values in an HTML table format.
<html>
<head><title>Squares & Cubes</title></head>
<body>
<center>
<table border="1">
<tr><th>number</th><th>square</th><th>cube</th></tr><script> for(vari=0;i<=10;i++)
{ document.write("<tr><td>"+i+"</td><td>"+i*i+"</td><td>"+ i*i*i+"</td></tr>"); }
</script></table></center></body></html>
OUTPUT:
}
}
</script>
</head>
<body id = "test" onload = "drawShape();">
<canvas id = "mycanvas"></canvas>
</body>
</html>
OUTPUT:
PART-B
1. Develop & demonstrate a HTML document that illustrates
The use of formatting text
Heading tags (H1 to H6)
Font details (font size, style, type and colour)
Setting colour (Bgcolor)
<html>
<head>
<Title>Formatting text, Heading tags,Fontdetails,setting color</title>
<body bgcolor=”yellow”>
<b> SRNMN COLLEGE </b>
<i> SRNMN COLLEGE </i>
<U> SRNMN COLLEGE </U>
<small>THIS IS A SMALLER TEXT </small>
<p>My address is <ins>Shimoga</ins></p>
<p>My address is <sub>Shimoga</sub></p>
<p>My address is <sup>Shimoga</sup></p>
<p>My address is <del>Shimoga</del></p>
</font>
</head>
</html>
OUTPUT:
<caption>Personal Details</caption>
<br><br>
<tr><th colspan=”2”>Name</th>
<th rowspan=”2”>Contact Number</th>
</tr>
<tr><th>First Name</th>
<th>Second Name</th>
</tr>
<tr><td>
Sahana</td><td>Kumar</td><td>1234567890</td></tr>
<tr><td>
Sneha</td><td>Kumar</td><td>9234567890</td></tr></table></body>
</html>
OUTPUT:
3.Create StyleSheet to set formatting for text tags and embed that StyleSheet on
WebPages Created For Your Site.
<html>
<head>
<title>Working with External Style Sheet</title>
<link rel=”stylesheet” href=”mystyle.css”></head>
<body>
<P class=”question”>How To Create <span class=”big”> Style Sheet?</span>
To alter an HTML Element? </P>
<P class=”answer”>The Style Assignment Process Accomplished with the Style Tags.</P>
</body>
</html>
File with Extension.css:Code for mystyle.css
P {font-size:12pt ; font-weight:bold; text-align:justify}
.question{color:red ; font-style:italic}
.answer{ color:#23238e }
.big{ font-size:14pt ; text-decoration:underline ;text-transformation:uppercase ; color:blue}
OUTPUT:
OUTPUT:
<td><label>User name:</label></td>
<td><input type="text" name="username" id="username" placeholder="your name"></td>
</tr>
<tr>
<td><label>password:</label></td>
<td><input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><label>phone number:</label></td>
<td><input type="phonenumber" name="phonenumber" id="phonenumber"></td>
</tr>
<tr>
<td><label>about:</label></td>
<td><textarea name="about" id="about" placeholder="write about
yourself"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="submit" name="submit"></td></tr>
<tr>
<td colspan="2">
<input type="reset" value="reset" name="reset"></td>
</tr>
</table>
</form>
</div><body><script>
document.registration.onsubmit=function form validation()
{
var name=document.getElementById("username"); var
password=document.getElementById("password");
varphonenumber=document.getElementById("phonenumber");
if(name.value.length<2||name.value.length>20)
{
alert("Characters must be less than 20");
this.name.focus(); return false;
}
if(!password.value.match(/^{5,15}$/))
{
alert("invalid password!!!.enter a vaild password");
this.password.focus();
return false;
}
if(!phonenumber.value.match(/^[1-9][0-9]{9}$/))
{
alert("invalid phonenumber!!!.enter a vaildphonenumber");
this.phonenumber.focus(); return false;
}
return true;
}
</script>
</body>
</html>
OUTPUT:
width: 250px; border: 5px solid black; border-radius: 3px; padding: 20px;
margin: auto;
}
</style>
</head>
<body>
<div class= "formstyle"><form name = "form1”>
<input id = "calc" type ="text" name = "answer"><br><br>
<input type = "button" value = "1" onclick = "form1.answer.value += '1' ">
<input type = "button" value = "2" onclick = "form1.answer.value += '2' ">
<input type = "button" value = "3" onclick = "form1.answer.value += '3' ">
<input type = "button" value = "+" onclick = "form1.answer.value += '+' ">
<br><br>
<input type = "button" value = "4" onclick = "form1.answer.value += '4' ">
<input type = "button" value = "5" onclick = "form1.answer.value += '5' ">
<input type = "button" value = "6" onclick = "form1.answer.value += '6' ">
<input type = "button" value = "-" onclick = "form1.answer.value += '-' ">
<br><br>
<input type = "button" value = "7" onclick = "form1.answer.value += '7' ">
<input type = "button" value = "8" onclick = "form1.answer.value += '8' ">
<input type = "button" value = "9" onclick = "form1.answer.value += '9' ">
<input type = "button" value = "*" onclick = "form1.answer.value += '*' ">
<br><br>
<input type = "button" value = "/" onclick = "form1.answer.value += '/' ">
<input type = "button" value = "0" onclick = "form1.answer.value += '0' ">
<input type = "button" value = "." onclick = "form1.answer.value += '.' ">
OUTPUT:
07. Develop and demonstrate a HTML5 file that includes Javascript script that uses
functions for the following problems
a)Parameter:A string
b)Output:The position in the string of the left-most vowel
c)Parameter:A number
d)Output:The number with its digits in the reverse order
<!doctype html>
<html>
<body>
<script type="text/javascript">varstr=prompt("enter the input"); if(!(isNaN(str)))
{
varnum,rev=0,remainder; num=parseint(str); while(num!=0)
{
remainder=num%10;
num=parseint(num/10); rev=rev*10+reminder;
}
alert("Reverse of "+str+" is"+rev);
}
else
{
str=str.toUppercase(); for(var i=0;i<str.length;i++)
{
Var chr=str.charAt(i);
if(char=='A'|| char=='E'|| char=='I'|| char=='O'|| char=='U') break;
}
if(i<str.length)
alert("The position of the left most vowel is"+(i+1)); else alert("No vowel is found in the
enterd string");
}
</script>
</body>
</html>
OUTPUT:
08.Write an HTML page that contains a solution box with a list of 5 countries. When the
user selects a country,its capital should be printed next in the list. Add CSS properties.
<html>
<head>
<title>Country with capital</title>
<body>
Select A country:
<select id="country" onchange="getCapital();">
<option value="0">INDIA</option>
<option value="1">RUSSIA</option>
<option value="2">ITALY</option>
<option value="3">FRANCE</option>
<option value="4">JAPAN</option></select>CAPITAL:
<input type="text" id="textbox">
<script> function getCapital()
{
var cap=["DELHI","MOSCOW","ROME","PARIS",TOKYO"];
var i=document.getElementById("country").selectedoptions[0].value;
document.getElementById("textbox").value=cap[i];
}
</script>
</body>
</html>
OUTPUT: