Professional Documents
Culture Documents
LAB MANUAL
( 2018–19 )
17CSL77
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
<head>
<title>Airthmetic Operations</title>
</head>
<script type="text/javascript">
function
addition()
var x,y,z;
x=
parseFloat(calc.value1.value);
y = parseFloat(calc.value2.value);
z =(x+y);
calc.value3.value = z;
}
function substraction()
var x,y,z;
x = calc.value1.value;
y = calc.value2.value;
z = x-y;
calc.value3.value = z;
function multiplication()
var x,y,z;
x = calc.value1.value;
y = calc.value2.value;
z = x*y;
calc.value3.value = z;
function division()
var x,y,z;
x = calc.value1.value;
y = calc.value2.value;
z = x/y;
calc.value3.value = z;
</script>
<body>
<h1>Online Calculator</h1>
</body>
</html>
Dept. of CSE Page 2
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
PROGRAM 2: Write a JavaScript that calculates the squares and cubes of the
numbers from 0 to 10 and outputs HTML text that displays the resulting values in
an HTML table format.
CODE :
<!DOCTYPE html>
<head>
</head>
<body bgcolor="lightblue">
<script>
for(i=0;i<=10;i++)
document.write("<tr><td>"+i+"</td><td>"+(i*i)+"</td><td>"+(i*i*i)+"</td> </tr>");
</script>
</tr>
</table>
</body>
</html>
Dept. of CSE Page 5
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
var c = 0,
t1;
function
start()
{
t1 =
window.setInterval("incr()", 100);
}
function incr() {
c = c + 1;
t.innerHTML = "TEXT-GROWING : " + c + "pt";
t.style.fontSize = c + "pt";
window.status = c;
if (c > 50) {
window.clearTimeout(t1);
}
t.style.color = "red";
}
function decr() {
c = c - 1;
t.innerHTML = "TEXT-SHRINKING: " + c + "pt";
t.style.fontSize = c + "pt";
window.status = c;
if (c == 5) {
window.clearTimeout(t1);
}
t.style.color = "blue";
}
</script>
</head>
<body bgcolor="#ffdead" onload="start()">
<center>
<p id="t"></p>
</center>
</body>
</html>
<head>
<title>JavaScript Functions</title>
<style>
.tb {
padding: 4px 22px 4px 4px;
border:1px solid red;
width:230px;
height:20px;
font:10pt verdana;
}
</style>
</head>
<body>
<h1 style="color: darkred;">JavaScript to </h1>
<h2 style="color: darkblue;">
<ul>
</h2>
<hr>
<br/>
<p style="font-size: 14pt;"><b>Enter String/Number: </b>
text += "The position of the leftmost vowel " + str.charAt(i) + " is: " + pos
+ "</h3><br/>";
document.getElementById("result").innerHTML =
text; exit;
}
}
}
</script>
</body>
</html>
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
PROGRAM 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.
CODE :
pgm5.xml :
<student>
<sname>ABCD</sname>
<usn>1PE15CS001</usn>
<college>PEST-BSC</college>
<branch>CSE</branch>
<yoj>2015</yoj>
<email>adcd@xyz.com</email>
</student>
<student>
<sname>QUERTY</sname>
<usn>1PE15CS002</usn>
<college>PEST-BSC</college>
<branch>CSE</branch>
<yoj>2015</yoj>
<email>querty@xyz.com</email>
</student>
<student>
<sname>PQRS</sname>
<usn>1PE15CS003</usn>
<college>PEST-BSC</college>
<branch>CSE</branch>
<yoj>2015</yoj>
<email>pqrs@xyz.com</email>
</student>
</student>
student.css :
student{
background_color :bisque;
font_family :'cambria';
}
student{
display : block;
margin bottom : 30pt;
margin_left "0;
}
sname{
display : block;
font_size "15pt;
text_transform:uppercase;
color:blue;
}
usn:before{
content: "usn:";
font_size:14pt;
font_weight:bold;
}
usn{
display:block;
font_size:14pt;
margin_left:20pt;
text_transform:uppercase;
color:blueviolet;
}
college:before{
content:"affiliated college:";
font_size:14pt;
font_weight:bold;
}
college{
display:block;
font_size:14pt;
margin_left:20pt;
color:blueviolet;
}
college:before{
content:"branch:";
font_size:14pt;
font_weight:bold;
}
branch{
display:block;
font_size:14pt;
margin_left:20pt;
color:blueviolet;
}
yoj:before{
content:"year of joining:";
font_size:14pt;
margin_left:20pt;
color:blueviolet;
}
yoj{
display:block;
font_size:14pt;
margin_left:20pt;
color:blueviolet;
}
email:before{
content:"emailid:";
font_size:14pt;
font_weight:bold;
}
email{
display:block;
font_size:14pt;
margin_left:20pt;
color:blueviolet;
}
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
PROGRAM 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.
CODE :
<?php
$file='count.txt';
$count=strval(file_get_contents($file));
file_put_contents($file,$count+1);
?>
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
PROGRAM 7 : Write a PHP program to display a digital clock which displays the current time
of the server.
CODE :
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h2>
<?php
date("d-m-Y"); date_default_timezone_set('Asia/Kolkata');
echo " </span> and Current Time is <span style='color:red';>" . date("h:i:s a") .
"</span>"; ?>
<!DOCTYPE html>
<html>
<head> <meta
</head>
<body>
<table>
<option>Select Operation</option>
<option value="+">Addition</option>
<option value="-">Subtraction</option>
<option value="*">Multiplication</option>
<option value="/">Division</option>
<option value="%">Remainder</option>
</select> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['pop'])) {
$num1 = $_POST["first"];
$num2 = $_POST["second"];
$op = $_POST["op"];
$result = 0;
switch($op)
?>
</body>
</html>
Dept. of CSE Page 17
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
pgm8bc.php :
<?php
header('Content-Type: text/plain');
echo "\n\n\n";
$rowCount
=
count($matrix1);
$colCount = count($matrix1[0]);
echo "\n";
echo "\n";
echo "\n";
$rowCount2 = count($matrix2);
$colCount2 = count($matrix2[0]);
echo "\n";
if($colCount == $rowCount2)
$val=0;
echo $val."\t";
echo "\n";
else {
?>
Dept. of CSE Page 21
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
PROGRAM 9 : 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 statesList.
b. Search for a word in states that begins with k and ends in s. Perform a caseinsensitive
comparison. [Note: Passing re.Ias a second parameter to method compile performs a
case-insensitive comparison .]Store this word in element1of statesList.
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.
CODE :
<?php
header('Content-Type: text/plain');
$i = 0;
$statesArray[$i] = ($state);
$i = $i + 1;
if (preg_match('/^k.*s$/i', ($state))) {
$statesArray[$i] = ($state);
$i = $i + 1;
echo "\nThe states that begins with k ans ends in s:" . $state;
foreach($states1 as $state) {
if (preg_match('/^M.*s$/', ($state))) {
$statesArray[$i] = ($state);
$i = $i + 1;
echo "\nThe states that begins with M and ends in s:" . $state;
if(preg_match('/as /',($state))) {
$statesArray[$i] = ($state);
$i = $i+1;
foreach($statesArray as $element=>$value) {
?>
Dept. of CSE Page 23
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
PROGRAM 10 : Write a PHP program to sort the student records which are stored in the
database using selection sort.
CODE:
<!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 = "";
$dbname = "weblab";
$a=[];
$conn = mysqli_connect($servername,$username,$password,$dbname); if
($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
echo "<br>";
echo "<center> BEFORE SORTING </center>";
echo "<table border='2'>";
echo "<tr>";
echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
if ($result->num_rows> 0)
{
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>". $row["usn"]."</td>";
echo "<td>". $row["name"]."</td>";
echo "<td>". $row["addr"]."</td></tr>";
array_push($a,$row["usn"]);
}
}
else
echo "Table is Empty";
echo "</table>";
$n=count($a);
$b=$a;
for ( $i = 0 ; $i< ($n - 1) ; $i++ )
{
$pos= $i;
for ( $j = $i + 1 ; $j < $n ; $j++ ) {
if ( $a[$pos] > $a[$j] )
$pos= $j;
}
if ( $pos!= $i ) {
$temp=$a[$i];
$a[$i] = $a[$pos];
$a[$pos] =
$temp;
}
}
$c=[];
$d=[];
$result =
$conn->query($sql);
if ($result->num_rows> 0)
{
while($row = $result->fetch_assoc()) {
for($i=0;$i<$n;$i++) {
if($row["usn"]== $a[$i]) {
$c[$i]=$row["name"];
$d[$i]=$row["addr"];
}
}
}
}
echo "<br>";
echo "<center> AFTER SORTING <center>";
echo "<table border='2'>";
echo "<tr>";
echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
for($i=0;$i<$n;$i++) {
echo "<tr>";
echo "<td>". $a[$i]."</td>";
echo "<td>". $c[$i]."</td>";
echo "<td>". $d[$i]."</td></tr>";
}
echo "</table>";
$conn->close();
?>
</body>
</html>