WEBPROGRAMMING PRACTICAL
WEBPROGRAMMING PRACTICAL
<html>
<head>
<title>Structure of WebPage</title>
</head>
<body>
<h1>Company Name</h1>
</body> </html>
Pract1 (B):Design a webpage using a Formatting Tags:-
<html>
<head>
</head>
<body>
italics</i></b>
<hr/>
</body> </html>
Pract1 (C):Design a webpage using a List Tags:-
<!DOCTYPE html>
<html>
<head>
<title>List Item</title>
</head>
<body>
<al type="2">
<li>HTML</li>
<li>CSS</li>
<li>PHP</li>
</ol>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>PHP</li>
</ul>
</body>
</html>
Pract1 (D):Design a webpage using a image and imagemap:-
<!DOCTYPE html>
<html>
<head>
<title> Images</title>
</head>
<body>
Available">
</body>
</html>
Image Map: <!DOCTYPE html>
<html>
<head>
<title>Click on Image</title>
</head>
<body>
<map name="workmap">
<area
shape="rect"
coords="34,44,270,350"
alt="Computer"
href="https://en.wikipedia.org/wiki/Computer"
د/
<area
shape="rect"
coords="290,172,333,250"
alt="Phone"
href="https://en.wikipedia.org/wiki/Mobile_phone"
/>
</map> </body>
Pract2 (A):Design a webpage using a Table Tag:-
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<th>Students</th>
<th>Total</th>
</tr>
<tr>
<td>Boys</td> <td>50</td>
</tr>
<tr>
<td>Girls</td>
<td>700</td>
</tr>
</table>
</body>
</html>
Pract2 (B):Design a webpage using a Form Tag:-
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>
</p>
<p>
</p> <p>
</p>
<p>
</p>
<p>
</form>
</body>
</html>
Pract2 (C):Design a webpage using a Navigation of multiple
webpages:-
<!DOCTYPE html>
<title>Navigation Links</title>
<html>
<head>
</head>
<body>
<div align="center">
</div>
</body> </html>
Pract2 (D):Design a webpage using a Embedded Multimedia
Elements:-
<!DOCTYPE html>
<html>
<head>
<title>Video Insertion</title>
</head>
<body>
</video>
</body>
</html>
Pract3 (A):Design a webpage that makes use of cascading style sheet with CSS
properties to change the background of page:-
<!DOCTYPE html>
<html>
<head>
<style>
h1{
background-color:green;
p{
background-color: yellow;
</style>
</head>
<body>
<div>
</div>
</body> </html>
Pract3 (B):Design a webpage that makes use of cascading style sheet with CSS
properties to change the fonts and text styles of page:-
<!DOCTYPE html>
<html>
<head>
<style>
p.normal{
font-style: normal;
p.italic{
font-style: italic;
p.oblique{
font-style: oblique:
</style>
</head>
<body>
</body> </html>
Pract3 (C):Design a webpage that makes use of cascading style sheet with CSS
properties for positioning an element:-
<!DOCTYPE html>
<html>
<head>
<style>
div.static{
position: static;
p.relative{
position: relative;
left: 30px;
</style>
</head>
<body>
<h2>Position: static</h2>
<div class="static">
</div>
</body></html>
Pract4 (A 1):Write A Javascript program for calculating Factorial of
number:-
<!DOCTYPE html>
<html>
<head>
<script>
function show(){
var i,no,fact;
fact=l:
no=Number(document.getElementById("num").value);
for(i=1;i<=no;i++)
fact=fact*i;
document.getElementById("answer").value=fact;
</script>
</head>
<body>
<button onclick="show()">Factorial</button>
<input id="answer">
</body></html>
Pract4 (A 2):Write A Javascript program for Finding Fibonacci
series:-
<!DOCTYPE html>
<html>
<head> </head>
<body>
<script> var n1 = 0.
n2 = 1, nextnum,
i;
var num = prompt(" Enter the limit for Fibonacci Series ");
document.write("Fibonacci Series: ");
n1 = n2;
n2 = nextnum;
</script>
</body>
</html>
Pract4 (A 3):Write A Javascript program for displaying prime
numbers:-
<!DOCTYPE html>
<html>
<head>
<script>
function calcprimeno(){
var ctr=beginno;
while (ctr<=endno) {
if (isPrime(ctr)==true) {
primeNumbs[prime Numbs.length]=ctr;
ctr=ctr+1;
if (primeNumbs.length==0) {
document.getElementById('output_content').innerHTML="There were no
else{
outputPrimeNums(primeNumbs):
}
}
function isPrime(num){
var flag=true;
flag=false;
break;
return flag:
function outputPrimeNums(primes){
html += primes[i]+"<br>";
document.getElementById('output_content').innerHTML=html;
</script>
</head>
<body>
<form name="numbers">
</form>
<div id="output_content"></div>
</body></html>
Pract4 (A 4):Write A Javascript program for Evaluating Expressions:-
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction(){
var x=10;
var y=20;
var a=eval("x"y")+"<br>";
var b=eval("2+2")+"<br>";
var c=eval("x+17")+"<br>";
var res=a+b+c:
document.getElementById("demo").innerHTML=res;
} </script>
</body> </html>
Pract4 (A 5):Write A Javascript program for Finding Reverse
Number:-
<!DOCTYPE html>
<html>
<head>
<script>
function palin(){
var a,no,b,temp=0;
no=Number(document.getElementById("no_input").value);
b=no;
while(no>0){
a=no%10;
no=parseInt(no/10):
temp-temp*10+a:
alert(temp);
</script>
</head>
<body>
<button onclick="palin()">Check</button><br><br>
</body></html>
Pract4 (B):Write A Javascript program for Validating various form
elements:-
<!DOCTYPE html>
<html>
<head>
<script>
function validateform() {
return false;
}else if(cpassword!=password){
dotposition+2=email.length){
dotposition:"+dotposition);
}else{
</script>
<title>Document</title>
</head>
<body>
<form
name="myform"
method="post"
action="abc.jsp"
onsubmit="return validateform()"
</form>
</body>
</html>
Pract5 (A1):Write A Javascript program for demonstrating regular
expressions:-
<!DOCTYPE html>
<html>
<body>
<p>Regular Expression</p>
<script>
function myFunction(){
var str="All these are not possible using HTML!"; var n=str.search(/possible/i);
document.write("<br>"+n+"<br>");
var res=str.replace(/possible/i,"POSSIBLE");
document.write("<br>"+res+"<br>");
var patt=/e/;
document.write("<br>"+patt.test(str)+"<br>");
</script>
</body>
</html>
Pract5 (A2):Write A Javascript program for demonstrating string:- <!DOCTYPE
html>
<html>
<body>
<script>
var strl="Hey diddle diddle, the cat and the fiddle, the cow jumped over the
moon.";
var str2="The little dog laughed to see such fun, and the dish ran away with the
spoon!";
document.write(strl+"<br>"+str2+"<br>");
var sln=strl.length;
document.write("<br>"+x+"<br>");
document.write("<br>"+y+"<br>");
</script>
</body>
</html>
Pract5 (A3):Write A Javascript program for demonstrating math:- <!DOCTYPE
html>
<html>
<body>
<script>
document.write("PI"+Math.PI+"<br>");
document.write("Random number="+Math.round(49.657)+"<br>");
document.write("rounding="+Math.round(6.433)+"<br>");
document.write("pow="+Math.pow(10,3)+"<br>");
document.write("Square root="+Math.sqrt(64)+"<br>");
document.write("absolute="+Math.abs(-67.7)+"<br>");
document.write("ceil="+Math.ceil(6.4)+"<br>");
document.write("floor="+Math.floor(4.7)+"<br>");
document.write("sin="+Math.sin(90*Math.PI/180)+"<br>");
document.write("cos="+Math.cos(0*Math.PI/180)+"<br>");
document.write("finding max="+Math.max(0,150,30,20,-8.-200)+"<br>");
document.write("finding min="+Math.min(0,150,30,20,-8,-200)+"<br>");
</script>
</body>
</html>
Pract5 (A4):Write A Javascript program for demonstrating date:- <!DOCTYPE
html>
<html>
<body>
<h2>Date Demonstration</h2>
<script>
document.write(Date());
document.write("<br>"+d+"<br>");
document.write("<br>"+d4+"<br>");
document.write("<br>"+"d.toUTCString()"+d.toUTCString());
</script>
</body>
</html>
Pract5 (B1):Write A Javascript program for demonstrating WINDOW object:-
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<script>
function del(){
if(ans==true){
alert("OK");
}else{
alert("Cancel");
</script>
</body> </html>
Pract5 (B2):Write A Javascript program for demonstrating Navigator object:-
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<script>
document.write("<br>navigator.cookieEnabled:"+navigator.cookieEnabled);
document.write("<br>navigator.userAgent:"+navigator.userAgent);
document.write("<br>navigator.appName:"+navigator.appName);
document.write("<br>navigator.appVersion:"+navigator.appVersion);
document.write("<br>navigator.platform:"+navigator.platform);
document.write("<br>navigator.language:"+navigator.language);
document.write("<br>navigator.online:"+navigator.online);
</script>
</body>
</html>
Pract5 (B3):Write A Javascript program for demonstrating History object:-
<!DOCTYPE html>
<script>
function goBack(){
window.history.back()
</script>
<title>Document</title>
</head>
<body>
</body> </html>
Pract5 (B4):Write A Javascript program for demonstrating Location object:-
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<script>
function myFunc(){
location.replace("http://www.google.com")
</script>
</body> </html>
Pract5 (C):Write A Javascript program for Storing and Retrieving Cookies:-
<!DOCTYPE html>
<html lang="en">
<head>
<script>
function set_cookie(c_name,c_value,exdays){
dt.setTime(dt.getTime()+(exdays*24*60*60*1000));
var exp="expires="+dt.toGMTString();
document.cookie=c_name+"="+c_value+":"+exp+";path=/";
function get_cookie(c_name){
var name=c_name+"=";
var decoded_cookie-decodeURIComponent(document.cookie);
var ca=decoded_cookie.split(':');
for(var i=0;i<ca.length;i++){
var x=ca[i];
while(x.charAt(0)=="){
x=x.substring(1);
if(x.indexOf(name)==0){
}
return x.substring(name.length,x.length);
return
||||
function check_cookie(){
var user=get_cookie("username");
if(user != ""){
alert("Welcome again"+user);
}else{
set_cookie("username",user.20);
</script>
</head>
<body onload="check_cookie()">
</body> </html>
Practical 6(A):create a xml file with internal/external DTD and display it using
CSS
<!DOCKTYPE book[
<!ELEMENT bname(#PCDATA)>
<!ELEMENT author(#PCDATA)>
]>
<book>
<bname>@ashwithyou_ </bname>
<author>TutorialsPoint</author>
<price>(011) 123-4567</price>
</book>
Practical 6(B): Create a xml file with internal/external DTD and display it using
XSL.
<xsl:stylesheetversion="1.0">
-<xsl:template match="/">
-<html>
-<body>
-<table border="1">
-<tr bgcolor="#ffff0000">
<th>BOOK ID</th>
<th> AUTHOR</th>
<th>PUBLISHER</th>
<th> PRICE</th>
-<xsl:for-each select="class/book"/>
-<tr>
-<td>
-<xsl:value-of select="@bid"/>
</td>
-<td>
-<xsl:value-of select="bname"/>
-</td>
-<td>
-<xsl:value-of select="publisher"/> </td>
-<td>
-<xsl:value-of select="price"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Practical 7(A):Design a webpage to handle asynchronous request using AJAX
onmouseover.
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<script>
function showDoc(){
xhttp.onreadystatechange=function(){ if(xhttp.readyState==4){
if(xhttp.status==200){
document.getElementById("show").innerHTML=xhttp.responseText;
};
xhttp.open("get"."My_File.txt",true);
xhttp.send();
</script></body></html>
Practical 7(B): Design a webpage to handle asynchronous requests using AJAX
on button click.
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<div id="show"></div>
<script>
function showDoc(){
xhttp.onreadystatechange=function(){
if(xhttp.readyState==4){
if(xhttp.status==200){
document.getElementById("show").innerHTML=xhttp.responseText:
};
xhttp.open("get","My_File.txt",true);
xhttp.send();</script> </body></html>
Pratical 8(A):write php scripts for retrieving data from HTML forms.
Form1.html:
<html>
<body>
</form>
</body>
</html>
Welcome.php
<?php
?>
Practical 8(B):performing certain mathematical operation such as calculating
factorial/finding Fibonacci series/displaying prime numbers in a given
range/evaluating expressions/calculating
reverse of a number.
1.Factorial:
<?php
$num=4;
$fact=1;
for($x=1;$x<=$num:$x++){
$fact=$fact*$x:
?>
2.Fibonacci series:
<?php
$num=10;
$a=0;
$b=1;
?>
echo $c=$a+$b;
echo "";
$a=$b;
$b=$c;
3.prime numbers:
<?php $n=50;
break;
if($k==$j){
?>
4.reverse number:
?>
Practical 8(C):Write PHP scripts for working with arrays.
<!DOCTYPE html>
<html>
<body>
<?php
$num=array(1,2,3,4,5):
foreach($num as $v){
?>
echo "Value=$v";
</body>
</html>
Practical 8(D):Write PHP script for working with files(reading/writing).
<html>
<body>
<?php
?>
</body> </html>
2.File reading:
<?php
$filename = "data.txt";
?>
Practical 9(A): write php scripts for working with databases.
<?php
$servername="localhost":
$username="root":
Spassword="1234":
$dbname="myDB":
if($conn->connect_error){
if($conn->query($sql)==TRUE){
}else{
$result=$conn->query($sql); if($result->num_rows>0){
while($row=$result->fetch_assoc()){
".$row["firstname"]."".$row["lastname"]."<br>";
}
}else{
$conn->close();
?>
Practical 9(B): write php scripts for storing and retrieving cookies.
<?php
setcookie("user","Guest");
?>
<html>
<body>
<?php
if(!isset($_COOKIE["user"])){
}else{
?>
</body>
</html>
Practical 9(C):write php scripts for storing and retrieving sessions.
<?php
session_start();
?>
<html>
<body>
<?php
$_SESSION["favcolor"]="Green":
$_SESSION["favflower"]="Rose";
?>
</body>
</html>
Practical 10: design wepage with some jQuery animation effects.
<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left: '250px'});
});
});
</script> </head>
<body>
<button>Start Animation</button>
<div
style="background:#98bf21;height:100px;width:100px;position:absolute;"></d
iv>
</body> </html>