Web Lab Manual
Web Lab Manual
PROGRAM:
<!DOCTYPE
HTML> <html>
<head>
<style>
table, td, th
<script type="text/javascript">
function calc(clicked_id)
{
Var val1 =
parseFloat(document.getElementById("value1").value);
var val2 =
parseFloat(document.getElementById("value2").value);
if(isNaN(val1)||isNaN(val2))
alert("ENTER VALID NUMBER");
else if(clicked_id=="add")
document.getElementById("answer").value=val1+val
2;
else if(clicked_id=="sub")
document.getElementById("answer").value=val1-
val2;
else if(clicked_id=="mul")
document.getElementById("answer").value=val1*val2;
else if(clicked_id=="div")
document.getElementById("answer").value=val1/val2;
function cls()
value1.value="0";
value2.value="0";
answer.value="";
</script>
</head>
<body>
<table>
onclick="calc(this.id)"/></td>
</body>
</html>
Output:
PROGRAM2.HTML
<!DOCTYPE
HTML> <html>
<head>
<style> table,tr,
td
{
border-collapse: collapse;
background-
color:lightblue;
}
</style>
<script>
document.write( "<tr><td>Number</td><td>Square</td><td>Cube</td></tr>" );
for(var n=0; n<=10; n++)
{
document.write( "</table>" ) ;
</script>
</head>
</html>
Output:
Experiment 4
Program 3.html
<!DOCTYPE HTML>
<html>
<head>
<style>
p{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<p id="demo"></p>
<script>
if(fs >= 50 ){
clearInterval(var1);
}
function deTimer() {
fs -= 5;
ids.innerHTML = 'TEXT SHRINKING';
ids.setAttribute('style', "font-size: " + fs + "px; color:
blue"); if(fs === 5 ){
clearInterval(var2)
</script>
</body>
</html>
Output:
S
H
R
I
N
K
I
N
G
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
Aim:
To write a JavaScript : position in the string of the left-most vowel and number with
its digits in the reverse order
Program 4.html
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
var num,rev=0,remainder;
num = parseInt(str);
while(num!=0) {
remainder = num%10;
num = parseInt(num/10);
rev = rev * 10 + remainder;
}
if( i < str.length )
else
</script>
</body>
</html>
Output :
Experiement 5
Design an XML document to store information about a student in
an engineering college affiliated to VTU. The information must
include USN, Name, and Name of the College, Branch, Year of
Joining, and email id. Make up sample data for 3 students. Create
a CSS style sheet and use it to display the document.
Program 5.xml
<!DOCTYPE HTML>
<html>
<head>
</head>
<students>
<student>
<USN>USN : 1ME15CS001</USN>
<name>NAME : SANVI</name>
<college>COLLEGE : MSEC</college>
<branch>BRANCH : Computer Science and Engineering</branch>
<year>YEAR : 2015</year>
<e-mail>E-Mail : [email protected]</e-mail>
</student>
<student>
<USN>USN : 1ME15IS002</USN>
<name>NAME : MANORANJAN</name>
<college>COLLEGE : MSEC</college>
<branch>BRANCH : Information Science and Engineering</branch>
<year>YEAR : 2015</year>
<e-mail>E-Mail : [email protected]</e-mail>
</student>
Program 5.css
student{
college{
branch{
year{
display:block; margin-left:20px;font-size:14pt; color:Green;
{
e-mail{
Sample Output:
STUDENTS DESCRIPTION
Experiment 6
Write a PHP program to keep track of the number of
visitors visiting the web page and to display this count of
visitors, with proper headings.
Program 6.php
<?php
$name="counter.txt";
$file = fopen($name,"r");
$hits= fscanf($file,"%d");
fclose($file);
$hits[0]++;
$file = fopen($name,"w");
fprintf($file,"%d",$hits[0]);
fclose($file);
?>
Sample Output:
REFRESH PAGE
Total number of views: 10
Experiment 7
Write a PHP program to display a digital clock which
displays the current time of the server.
Program 7.php
<!DOCTYPE HTML>
<html>
<head>
<style>
p{
color:white;
font-size:90px;
position: absolute;
top: 50%;
left: 50%;
body{background-color:black;}
</style>
</head>
Sample Output:
Experiment 8
<html>
<head>
<style>
table, td, th
{
border: 1px solid black;
width: 35%;
text-align: center;
background-color:
DarkGray;
}
table { margin: auto; }
input,p { text-align:right; }
</style>
</head>
<body>
<form method="post">
<table>
<caption><h2> SIMPLE CALCULATOR </h2></caption>>
<tr><td>First Number:</td><td><input type="text" name="num1"
/></td>
<td rowspan="2"><input type="submit"
name="submit"
value="calculate"></td></tr>
<tr><td>SecondNumber:</td><td><inputtype="text"
name="num2"/></td></tr>
</form>
<?php
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
if(is_numeric($num1) andis_numeric($num1) )
{
echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>";
echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>";
echo "<tr><td> Multiplication
:</td><td><p>".($num1*$num2)."</p></td>";
else
</body>
</html>
Sample Output:
EXPERIMENT 8B
<?php
$a = array(array(1,2,3),array(4,5,6),array(7,8,9));
$b = array(array(7,8,9),array(4,5,6),array(1,2,3));
$m=count($a);
$n=count($a[2]);
$p=count($b);
$q=count($b[2]);
echo "<br/>";
echo "<br/>";
echo "<br/>";
}
if(($m===$p) and ($n===$q)) {
}
if($n===$p){
$result=array();
Dept. of CSE, MSEC Page 21
Web Technology Lab With Mini Project – 15CSL77 2018-2019
$result[$i][$j] = 0;
Experim
Write a PHP program named states.py that declares a variable states with value
"Mississippi Alabama Texas Massachusetts Kansas". write a PHP program that does the
following:
a) Search for a word in variable states that ends in xas. Store this word in element
0 of a list named states List.
b) Search for a word in states that begins with k and ends in s. Perform a case
insensitive comparison. [Note: Passing re.Ias a second parameter to method
compile performs a case-insensitive comparison.] Store this word in element1 of
states List.
c) Search for a word in states that begins with M and ends in s. Store this word in
element 2 of the list.
d) Search for a word in states that ends in a. Store this word in element 3 of the list.
Aim:
Write a PHP program with variable states with value “Mississippi Alabama Texas Massachusetts
Kansas"
Program 9.php
<?php
$states = "Mississippi Alabama Texas Massachusetts
Kansas"; $statesArray = [];
$states1 = explode(' ',$states);
echo "Original Array :<br>";
foreach ( $states1 as $i => $value
)
print("STATES[$i]=$value<br>");
foreach($states1 as $state) {
if(preg_match( '/xas$/', ($state)))
$statesArray[0] = ($state);
}
foreach($states1 as $state) {
if(preg_match('/^k.*s$/i', ($state)))
$statesArray[1] = ($state);
}
foreach($states1 as $state) {
if(preg_match('/^M.*s$/', ($state)))
$statesArray[2] = ($state);
}
foreach($states1 as $state){
if(preg_match('/a$/', ($state)))
$statesArray[3] = ($state);
}
echo "<br><br>Resultant Array :<br>";
foreach ( $statesArray as $array => $value )
print("STATES[$array]=$value<br>");
?>
Sample Output:
Exp 10: PHP - program to sort the student records using selection
sort.
Write a PHP program to sort the student records which are stored in the database
using selection sort.
Aim:
To write a PHP - program to sort the student records using selection sort.
Goto Mysql and then type
create database weblab;
use weblab;
create table student(usnvarchar(10),name varchar(20),address varchar(20));
program10.php
<!DOCTYPE html>
<html>
<body>
<style>
table, td, th
{
border: 1px solid black;
width: 33%;
text-align: center;
border-collapse:collapse;
background-color:lightblue;
}
table { margin: auto; }
</style>
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "weblab";
$a=[];
// Create connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
Sample Output:
AFTER SORTING
USN NAME ADDRESS
1ME16 ABHAY BENGALURU
1ME15 ARUN HASSAN
1ME14 CHANDANA MANDYA
1ME13 SANJAY KOLAR