Main Practical File WD
Main Practical File WD
file
Department: Computer Science and
Class: MCA
Semester: 5th
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Syllabus
List of Practical
4 Introduction to CSS.
12 Introduction o Ajax.
Experiment 1
AIM: Introduction to HTML and XHTML
XHTML
XHTML stands for Extensible HyperText Markup Language and
is the next step in the evolution of the Internet. The XHTML 1.0 is
the first document type in the XHTML family.
Experiment 2
AIM: Basic Tags in HTML.
<html>
<head>
<body bgcolor=pink>
<h1>welcome to html</h1><br/>
<h2>creating tables</h2>
<table border="2">
<th>table head</th>
<tr>
<td>row1</td>
<td>row2</td>
</tr>
</table>
<input type="text"
name"text"> password
radio button<br/>
</br>
checkbox<br/
>
submit button<br/>
select box<br/>
<select>
<option>one </option>
<option>three </option>
<option>four </option>
</select>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 3
AIM: Write a program to create lists..
<html>
<body>
<ol>
<li>a</li>
<li>s</li>
</ol>
<ul>
<li>a</li>
<li>s</li>
</
ul>
<LI> Fruits
<LI> Apple
<LI> MANGO
<LI> Orange
Page 20 of
115
</OL>
<LI> VEGETABLES
<LI> Brinjal
<LI> Cabbage
<LI> Tomato
</OL>
</OL>
<dl>
</
dl>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 4
Example:-
<html>
<head>
<title>css</title>
<link rel="stylesheet" type="text/css" href="cs.css" />
<style type="text/css">
.di
{
background-
color:#99FF00; margin-
left:300px; width:100px;
height:100px;
}
.mm
{
background-
color:#660099;
width:200px;
height:100px;
}
#mn
{
background-
color:#3333FF; margin-
left:500px; width:300px;
height:300px;
}
#ss
{
background-
color:#3333FF;
width:300px;
height:100px;
}
</style>
</head>
<body>
<div id="container">
<h1>Inline CSS</h1>
<p style="color:#FF0000; margin-left:20px; font-
size:14px; background-color:#CCFF00; width:500px;
height:300px">
Inline CSS exaple for background color, font size, margin-
left and for width.</p>
<h1>internal CSS</h1>
<div class="di">
<table border="2">
<tr>
<td>row1</td>
<td>row2</td>
</tr>
</table>
</div>
<div id="mn">
<h1>introduction</h1><br/>
<b>tag for bold</b><br/>
<h2>about clg</h2><br/>
<h3>create options</h3>
passwords
<input type="password"rollno="pws"><br/>
</div><br/>
<br/>
<h1>external css</h1>
<p class="ab">external css</p>
</div>
<br />
<p id="sm">example for external css </p>
</div>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 5
AIM: Write a program to create menu using HTML and CSS..
<html>
<head>
<title>menu</title>
<link rel="stylesheet"
type="text/css" href="style.css" />
</head>
<body>
<ul><li>Home</li>
<li>About</li>
<li>
Portfolio
<ul>
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul>
</li>
<li>Blog
<ul>
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul></li>
<li>Contact</li>
<li>Facilities</li>
<li>Downloads
<ul><li>apendix c</li>
<li>apendix d</li>
<li>apendix g</li>
</ul>
</li>
</ul>
</body>
</html>
body {
font-family: Arial, Helvetica, sans-serif, Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align:
center;
background: #E3CAA1;
}
ul {
text-align:
left; display:
inline;
margin: 0;
padding: 15px 4px 17px
0; list-style: none;
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
cursor: pointer;
}
ul li:hover
{ background:
#555; color: #fff;
}
ul li ul
{ padding:
0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
opacity: 0;
visibility: hidden;
}
ul li ul li {
background: #CCCC33;
display: block;
color: #FF0000;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background:
#9966CC; } ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 6
AIM: Introduction to
JavaScript?
Experiment 7
AIM: Write a program to print date using JavaScript.
<!DOCTYPE html>
<html>
<body>
<button type="button"
onclick="myFunction()">print date</button>
<script>
function myFunction()
{
document.getElementById("demo").innerHTML = Date();
}
</script>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 8
AIM: Write a program to Sum and multiply two numbers using JavaScript.
<html>
<head>
<script>
function myFunction() {
var y =
document.getElementById("txt1").value; var z
= document.getElementById("txt2").value; var
x = +y + +z;
document.getElementById("demo").innerHTML =
x;
}
function mul() {
var y =
document.getElementById("txt1").value; var z
= document.getElementById("txt2").value; var
x = +y * +z;
document.getElementById("demo").innerHTML =
x;
}
</script>
</head>
<body>
<p>Click the button to calculate.</p>
<br/>
<br/>Enter first number:
<input type="text" id="txt1"
name="text1" size="6px">Enter second number:
<input type="text" id="txt2"
name="text2" size="6px"><br>
<button onClick="myFunction()">SUM</button>
<button onClick="mul()">Multiply</button>
<p id="demo"></p>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 9
AIM: Write a program to Show use of alert, confirm and prompt box.
<html>
<head>
<title>java script</title>
<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Welcome
Fb.com?") if (answer){
alert("Welcome!")
window.location
=
"http://www.fb.com/hatemyself90";
}
else{
alert("Bye bye!!")
}
}
//-->
<!--
function prompter() {
var reply = prompt("What's your name?",
"") alert ( "Nice to see you" + reply +
"!")
}
//-->
</script>
</head>
<body>
<h1 align="center"> Java Script Alert, Confirm
and Prompt Box. </h1>
<form style="height:200px; width:200px;
background- color:#CC3366;">
<h3> Java Script Alert Box.</h3>
<input type="button" onclick="alert('Are you sure
you want to give us the deed to your house?')"
value="Confirmation Alert">
</form>
Experiment 10
AIM: Write a program to redirect, popup and print function in JavaScript.
<html>
<head>
<title>java script</title>
<script type="text/javascript">
<!--
function delayer(){
// window.location = "../java/5.html"
window.location = "4.html"
}
//-->
<!--
function myPopup2() {
window.open( "http://www.google.com/", "myWindow",
"status = 1, height = 300, width = 300, resizable = 0"
)
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h1> Redirect, Popup and Print Function using
java script</h1>
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, please
update your bookmarks to our new
location!</p>
<form>
<input type="button" value="Print This
Page" onClick="window.print()" />
</form>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 11
AIM: Create validation Form in JavaScript..
<html>
<head>
<script type='text/javascript'>
function formValidator(){
// Make quick references to our fields
var firstname =
document.getElementById('firstname'); var addr =
document.getElementById('addr');
var zip = document.getElementById('zip');
var state = document.getElementById('state');
var username =
document.getElementById('username'); var email =
document.getElementById('email');
8)){ 6,
if(emailValidator(email,
"Please enter a valid email address")){
return true;
}
}
}
}
}
}
return false;
}
Experiment 12
AIM: Introduction o Ajax.
AJAX = Asynchronous JavaScript and XML
AJAX is not a new programming language, but a new way to use existing
standards.
AJAX is the art of exchanging data with a server, and updating parts of a web page
- without reloading the whole page.
Classic web pages, (which do not use AJAX) must reload the entire page if the
content should change.
Google Suggest
Google Suggest is using AJAX to create a very dynamic web interface: When you
start typing in Google's search box, a JavaScript sends the letters off to a server
and the server returns a list of suggestions.
As you type in the search box, you can find information quickly by seeing
searches that might be similar to the one you're typing. For example, as you start
to type [google], you may see searches for other popular google-related searches.
Experiment 13
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 14
variable=new XMLHttpRequest();
Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object:
variable=new ActiveXObject("Microsoft.XMLHTTP");
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
var xmlhttp;
if (window.XMLHttpRequest)
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
</script>
</head>
<body>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 15
PHP started out as a small open source project that evolved as more and more
people found out how useful it was. Rasmus Lerdorf unleashed the first version of
PHP way back in 1994.
Experiment 16
AIM: Write a program to Addition of two numbers using php.
<html>
<head>
<title>Addition of Numbers Using Forms</title>
</head>
<?php
error_reporting(0);
$value1 = trim($_REQUEST['val_1']);
$value2 = trim($_REQUEST['val_2']);
if ($_REQUEST['submit2']){
$value1 = "";
$value2 = "";
}
?>
<br>
<input type="submit" name="submit" value="Add">
<input type="submit" name="submit2" value="Clear">
</form>
<?php
if ($_REQUEST['submit']){
?>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 17
<html>
<head>
<title>PHP data types</title>
</head>
<body>
<?php
<br />
Now, converting to other types:<br />
<?php
Experiment 18
<html >
<head>
</head>
<body>
<?php
$a = 5;
define( "VALUE", 5 );
$a = $a + VALUE;
is $a <br />" );
// multiply variable $a by 2
$a *= 2;
print( "Multiplying variable a by 2 yields $a <br />" );
if ( $a < 50 )
// add 40 to variable $a
$a += 40;
if ( $a < 51 )
inclusive<br />" );
else
<br />" );
$test = $a + VALUE;
$a += $str;
<br />" );
?>
</body>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 19
AIM: Write a program to using class in php.
<?php
class Programmer {
// Class Properties
$this->name=$name;
$this->experience=$experience;
$this->lang=$lang;
$this->education=$education;
}
function get_name()
{ return $this->name;
function set_name($newname) {
$this->name = $newname;
function get_experience()
{ return $this-
>experience;
function set_experience($newexperience) {
$this->experience = $newexperience;
function get_lang()
{ return $this->lang;
function set_lang($newlang) {
$this->lang = $newlang;
function get_education()
{ return $this->education;
function set_education($neweducation) {
$this->education = $neweducation;
function output() {
// Instantiating a programmer
$paul->output();
$paul->set_experience(7);
$paul->output();
?>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 20
AIM: Write a program to connect to database.
<?php
$con=mysql_connect("localhost","root","");
if($con)
{
echo"connected"
; echo "<br>";
}
else
{
echo "not connected";
}
?>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 21
AIM: Write a program to insert data in database.
<?php
require_once("connect.php");
error_reporting(0);
if($_POST['submit'])
{
$fn=$_POST['name'];
$rn=$_POST['roll'];
$sn=$_POST['sem'];
mysql_select_db("exmp",
$con);
$query="INSERT INTO exmp1(name,roll,sem) VALUES ('$fn','$rn','$sn')";
if(mysql_query($query,$con))
{
header("Location:test.php");
}
else
{
echo"die";
}
}
?>
<html>
<head>
<body>
<form method="post" action="insert.php">
First name:<input type="text"
name="name"><br/><br/> stud roll:<input type="text"
name="roll"><br/><br/> stud sem :<input type="text"
name="sem"><br/><br/>
<input type="submit" name="submit" value="submit"><br/>
</form>
</body>
</head>
</html>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 22
AIM: Introduction to asp.
ASP stands for Active Server Pages. Microsoft introduced Active Server Pages in
December 1996, beginning with Version 3.0. Microsoft officially defines ASP as:
“Active Server Pages is an open, compile-free application environment in which
you can Combine HTML, scripts, and reusable ActiveX server components to
create dynamic and Powerful Web-based business solutions. An active Server
page enables server side scripting For IIS with native support for both VBScript
and Jscript.” (2). In other words, ASP is a Microsoft technology that enables
you to create dynamic web sites with the help of server Side script, such as
VBScript and Jscript. ASP technology is supported on all Microsoft Web servers
that is freely available. If you have Window NT 4.0 Server installed, you Can
download IIS (Internet Information Server) 3.0 or 4.0. If you are using Window
2000, IIS 5.0 comes with it as a free component. If you have Window 95/98, you
can Download Personal Web Server (PWS), which is a smaller version of IIS, from
Window 95/98 CD. You can also download these products for free from
Microsoft’s web site.
Well, you have learned what the ASP technology is. Next, you will learn about an
ASP file. Is it the same as HTML file? Let’s explore it.
Which are executed on the server? The two widely used scripting languages for
an ASP Page are VBScript and JScript. VBScript is pretty much like Visual Basic,
whereas Jscript is the Microsoft’s version of JavaScript. However, VBScript is
the default Scripting language for ASP (3). Besides these two scripting languages,
you can use other scripting language with ASP as long as you have an ActiveX
scripting engine for the language installed, such as PerlScript. The difference
between an HTML file and an ASP file is that an ASP file has the “.asp” extension.
Furthermore, script delimiters for HTML tags and ASP code are also different. A
script delimiter is a character that marks the starting and ending of a unit. HTML
tags begins with
lesser than (<) and greater than (>) brackets, whereas ASP script typically starts
with <% and ends with %>. In between the delimiters are the server-side scripts.
To write an ASP script, you don’t need any additional software because it
can be written with any HTML editor, such as Notepad. Nonetheless, if you feel
bored with the plain text and would like to use some special software, you can
use Microsoft visual InterDev, which helps you to easily create an ASP page by
giving you nice highlights and debugging dialogue boxes (4). I hope that you
already have an idea of what an ASP file is and how it is different from an HTML
file. In the next step, you will learn how ASP works. Let’s go
GURU JAMBHESHWAR UNIVERSITY OF
SCIENCE & TECHNOLOGY
Experiment 23
AIM: Write a program to generate login control.
Source:
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<div>
Inherits
System.Web.UI.Page
ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles
Login1.Authenticate
Else
MsgBox("Error:Loggedin")
End If
If Application("i") = 3 Then
MsgBox("You are Blocked")
Login1.Enabled = False
End If
End Sub
End If
End Sub
End
Class
Global Application:
<script runat="server">
0 End Sub
End Sub
End Sub
</script>
GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY
Experiment 24
AIM: Write a program to perform validation operation.
Source:
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator" Style="z-index: 118; left:
672px; position: absolute;
top: 72px">Must enter name</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="TextBox4"
ErrorMessage="RequiredFieldValidator" Style="z-index: 120; left:
672px; position: absolute;
top: 232px">Must enter dept</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server" ControlToValidate="TextBox3"
ErrorMessage="RequiredFieldValidator" Style="z-index: 121; left:
680px; position: absolute;
top: 184px">Must enter date of
birth</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox8"
Display="None"
ErrorMessage="RegularExpressionValidator" Style="z-
index: 126;
left: 656px; position: absolute; top: 512px"
ValidationExpression="(\(\d{3}\)|\d{3}
)?\d{8}"></asp:RegularExpressionValidator>
</div>
</form>
</body>
</html>
Code:
If IsValid Then
Label9.Enabled = False
TextBox7.Enabled =
False
End If