Web Technology
Tuesday, 14 January 2014
Monday, 24 June 2013
Digital Clock in Java script
<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
web programming
1.
Keral map
<html>
<head>
</head>
<body>
<imgsrc="kerala.jpg"
width="249" height="202" alt="Kerala"
usemap="#keralamap">
<map
name="keralamap">
<area
shape="rect" coords="100,52,122,73" href=""
title="Calicut - vas Co Da Gama has landed here!"
alt="Calicut">
<area
shape="rect" coords="128,111,154,131" href=""
title="Cochin-is a major port city on the west coast of India by the
Arabian Sea and is part of the district of Ernakulam of the state of
Kerala" alt="Cochin">
<area
shape="rect" coords="139,160,174,176" href=""
title="Kollam - An old sea port and town on the Arabian coast in Kerala,
India, on the AshtamudiLake " alt="Kollam">
<area
shape="rect" coords="151,177,179,198" href=""
title="Trivandrum - Capital of Kerala, located on the west coast of India
near the extreme south of the mainland" alt="Trivandrum">
</map>
</body>
</html>
</map>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
2.Counting number of anchor tags and images
<html>
<head>
<style>
li>a
{
text-align:center;
color:green;
}
h3 {text-decoration:underline;}
</style>
</head>
<body bgcolor="pink">
<h3>Count the number of images and
anchor tag in html</h3>
<h3>Anchor tags</h3>
<li>
<a name="html">HTML
Totorial</a></li>
<li><a name="display">Display
Cities</a></li>
<li><a
name="student">Student Marks</a></li></p>
<li>ddd</li>
<h3>Images</h3>
<image
src="html.gif"></image>
<image
src="http.gif"></image>
</br>
</br>
<input type="image"
onclick="redirect()" src="rose.jpeg" />
</br></br></br>
<img id="image"
src="rose1.jpeg"
onclick="moveleft()"
onclick="moveback()"
/></br></br></br>
<script>
document.write("count of anchor tag is
.............");
document.write(document.anchors.length+"<br>");
document.write("Number of
images.................");
document.write(document.images.length);
function redirect() {
window.location="displaydate.html";
}
functionmoveleft()
{
document.getElementById('image').style.position="absolute";
document.getElementById('image').style.left="0";
}
functionmoveback()
{
document.getElementById('image').style.position="absolute";
}
</script>
</body>
</html>
(3).website creation
<html>
<head>
<title>(Type a title for your page
here)</title>
<style>
h1
{
text-align:center;
color:blue;
font-family:"Times New Roman";
font-style:italic;
}
h2
{
text-align:left;
font-family:"Arial";
color:red;
}
h3
{
text-align:right;
color:green;
}
h4
{
color:violet;
}
body
{
background-color:#b0c4de;
}
#id1
{
font-family:"Times New Roman";
color:brown;
text-align:center;
}
</style>
</head>
<style>
</style>
<body onload=display_ct();>
<span id='ct' ></span>
<img type="button"
onclick="redirect" src="images.jpeg">
<h1><marquee>Inavista
software</marquee></h1>
<table><tr
border=1><td>PRODUCTS</td><td></td><td></td><td>SERVICES</td><tr>CONTACTS</tr></table>
<h2>ERP development</h2>
<h3>Inavista Birdie</h3>
<h4>chikago</h4>
<p id=id1> Imagine waving goodbye
to project failure once and for all: Eliminating stressful and unorganized
information silos; rediscovering efficient budget, time and cost management
processes; identifying and remedying serious issues before it̢۪s too late;
taking back control over your projects.</p>
<a href="newpage.html">
<img
src="html.gif"></a></p>
<image type="button"
onclick="redirect" src="http.gif" />
</body>
<script
type="text/javascript">
function display_c(){
var refresh=1000; // Refresh rate in
milli seconds
mytime=setTimeout('display_ct()',refresh)
}
function display_ct() {
var strcount
var x = new Date()
document.getElementById('ct').innerHTML
= x;
tt=display_c();
}
function redirect() {
window.location="homepage.html";
}
</script>
</html>
(4). Form creation
<html>
<head>
<style>
h2
{
text-align:center;
color:blue;
}
tr
{
color:blue;
}
#bt
{
color:brown;
}
</style>
</head>
<body>
<h2>FORM FORM</h2>
<form action="cookie.php"
method="post">
<table><tr><td>
Enter your name
:</td><td><input type="text" size=30
name="name"></br></br></td></tr>
<tr><td>
How often do you buy online
: </td><td><input type ="radio"
name="r1" value="every day">Every day</br>
</td>
<tr><td></td><td>
<input type ="radio" name="r1"
value="once a week">Once a week</br></td></tr>
<tr><td></td><td>
<input type ="radio" name="r1"
value="once a month">Once a month</br></td></tr>
<tr><td></td><td>
<input type ="radio" name="r1">Rarely</br></td></tr>
<tr><td>
Please select a product</br></td></tr>
<tr><td>
<input type ="checkbox" name="ch1[]"
value="appletree">apple tree($29)</td>
<td>
Number of purchase
<input type ="text" size=5
name="txt1"></br></td></tr>
<tr><td>
<input type ="checkbox" name="ch1[]"
value="orange tree" >orange tree ($10)</td><td>
Number of purchase
<input type ="text" size=5
name="txt2"></br></td></tr>
<tr><td>
<input type ="checkbox" name="ch1[]"
value="cherry tree">cherry tree ($29)</td>
<td>
Number of purchase
<input type ="text" size=5
name="txt3"></br></td></tr>
<tr><td>
<input type ="checkbox" name="ch1[]"
value="magnolia">magnolia tree($34)</td>
<td>
Number of purchase
<input type ="text" size=5
name="txt4"></br></td></tr>
<tr><td>
Select shipment:</td><td>
<select >
<option> FedEx</option>
<option> sbt </option>
</select></td></tr>
<tr><td><input type="submit" id=bt
value="Set Cookie"</td></tr>
</table></form>
</body>
</html>
<?php
$conn=mysqli_connect("localhost","root","","student");
echo "ffdf";
if(isset($_POST['ch1']))
{
foreach
($_POST['ch1'] as $_ch1Value)
{
echo "{$_ch1Value} was
selected!\n";
$items=$_ch1Value;
}
}
//echo $items;
echo "jhjjjjjjjjjj";
echo "ghghtgfuy";
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to
connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "no problem";
}
$sql="INSERT INTO productinfo (name, buy_type, product) VALUES('$_POST[name]','$_POST[r1]','$items')";
echo $sql;
if (!mysqli_query($conn,$sql))
{
die('Error: ' .
mysqli_error());
}
echo "1 record added";
mysqli_close($conn);
?>
(5). Online
examination
<html>
<body>
<h1>ONLINE EXAMINATION</h1>
<table>
<form action="result.php"
method="post">
<tr><td>
Question 1:Capital of India?</td></tr>
<tr><td>a.<input type ="radio"
name="q1" value="Delhi">Delhi</tr></td>
<tr><td>b.<input type ="radio"
name="q1" value="Kerala">Kerala</tr></td>
<tr><td>c.<input type ="radio"
name="q1"
value="Tamilnadu">Tamilnadu</tr></td>
<tr><td>d.<input type ="radio"
name="q1" value="Assam">Assam</tr></td>
<tr><td>
Question 1:Father of Computer?</td></tr>
<tr><td>a.<input type ="radio"
name="q2" value="Alan Turing">Alan Turing</tr></td>
<tr><td>b.<input type ="radio"
name="q2" value="Chalse Babage">Chalse
Babage</tr></td>
<tr><td>c.<input type ="radio"
name="q2"
value="Alexander">Alexander</tr></td>
<tr><td>d.<input type ="radio"
name="q2" value="Fernad">Fernad</tr></td>
<tr><td></td><td></td><td><input
type="submit" id=bt
value="submit"></td></tr>
</table>
</form>
</body>
</html>
<html>
<body>
<?php
echo "welcome";
$answ1=$_POST[q1];
$answ2=$_POST[q2];
$ans1=strcmp("Delhi",$answ1);
if($ans1=='0')
{
echo "your answer is correct";
}
else
{
echo "wrong";
}
$ans2=strcmp("Alan Turing",$answ2);
if($ans2=='0')
{
echo "your answer is correct";
}
else
{
echo "wrong";
}
$con=mysqli_connect("","root","","student");
echo $con;
if (mysqli_connect_errno())
{
echo "Failed to
connect to MySQL: " . mysqli_connect_error();
}
echo "kkkkkkkkkkkk";
$sql="INSERT INTO examination(qs1,qs2) VALUES('Delhi','Alan
Turing')";
echo $sql;
if (!mysqli_query($con,$sql))
{
die('Error: ' .
mysqli_error());
}
echo "1 record added";
mysqli_close($con);
?>
</body>
</html>
(6). Perl program
#!/usr/bin/perl -w
use DBI;
print "Content-type: text/html\n\n";
## mysql user database name
$db ="student";
## mysql database user name
$user = "root";
## mysql database password
$pass = "";
## user hostname : This should be "localhost" but it
can be diffrent too
$host="localhost";
## SQL query
$query = "show tables";
$dbh = DBI->connect("DBI:mysql:$db:$host", $user,
$pass);
$sqlQuery =
$dbh->prepare($query)
or die "Can't prepare $query: $dbh->errstr\n";
$rv = $sqlQuery->execute
or die "can't execute the query:
$sqlQuery->errstr";
print "<h3>********** My Perl DBI Test
***************</h3>";
print "<p>Here is a list of tables in the MySQL
database $db.</p>";
while (@row= $sqlQuery->fetchrow_array()) {
my $tables = $row[0];
print "$tables\n";
}
$rc = $sqlQuery->finish;
# invoke the ConnectToMySQL sub-routine to make the database
connection
# set the value of your SQL query
$query = "select * from productinfo";
# prepare your statement for connecting to the database
$statement = $dbh->prepare($query);
# execute your SQL statement
$statement->execute();
# retrieve the values returned from executing your SQL statement
print "Data from productinfo\n";
print "...........................\n";
print " NAME
TYPE PRODUCT \n";
while (@data = $statement->fetchrow_array()) {
$name_first = $data[0];
$buy_type = $data[1];
$product = $data[2];
# print your table rows
print "$name_first
$buy_type
$product\n";
}
# close your table
# exit the script
#exit;
exit(0);
Subscribe to:
Posts (Atom)