Web Technology

Ex : 1A                             TIME TABLE USING HTML TABLES
<html>
<!--table style="background-color:lightpink" border="4"--><br><br>
<table height="100" width="150"
 background="1.jpg" border="4">

<caption> <b><font face="ALGERIAN" size="4" color="Black">TIME TABLE</b></caption>

<tr>
<th align ="left"><font face="ALGERIAN" size="4" color="BLACK">DATE\PERIOD</th>
<th align ="center">1</th>
<th align ="center">2</th>
<th rowspan ="7" align ="center">Break</th>
<th align ="center">3</th>
<th align ="center">4</th>
<th rowspan ="7" align="center">Lunch</th>
<th align ="center">5</th>
<th align ="center">6</th>
<th align ="center">7</th>
</tr>

<tr>
<td align ="left"><font face="ALGERIAN" size="4" color="BLACK">MON</td>
<td align ="center">NS</td>
<td align ="center">ES</td>
<td align ="center">.NET</td>
<td align ="center">NS</td>
<td align ="center">WT</td>
<td align ="center">DWDM</dh>
<td align ="center">PT</td>
</tr>

<tr>
<td align ="left"><font face="ALGERIAN" size="4" color="BLACK">TUE</td>
<td align ="center">WT</td>
<td align ="center">NS</td>
<td align ="center">DWDM</td>
<td align ="center">WCN</td>
<td align ="center" colspan="3" >ES LAB</td>
</tr>
<tr>
<td align ="left"><font face="ALGERIAN" size="4" color="BLACK">WED</td>
<td align ="center">WT</td>
<td align ="center">WCN</td>
<td align ="center">SPD</td>
<td align ="center">DWDM</td>
<td align ="center" colspan="3">NS LAB</td>
</tr>

<tr>
<td align ="left"><font face="ALGERIAN" size="4" color="BLACK">THU</td>
<td align ="center">NS</td>
<td align ="center" colspan="4">WT LAB</td>
<td align ="center">.NET</td>
<td align ="center">WCN</td>
<td align ="center">DWDM</td>
</tr>

<tr>
<td align ="left"><font face="ALGERIAN" size="4" color="BLACK">FRI</td>
<td align ="center">WT</td>
<td align ="center">DWDM</td>
<td align ="center">NS</td>
<td align ="center">WCN</td>
<td align ="center">SEM</td>
<td align ="center">DM</td>
<td align ="center">NS</td>
</tr>

<tr>
<td align ="left"><font face="ALGERIAN" size="4" color="BLACK">SAT</td>
<td align ="center">DWDM</td>
<td align ="center">NS</td>
<td align ="center">.NET</td>
<td align ="center">SEM</td>
<td align ="center">DWDM</td>
<td align ="center">PROJ</td>
<td align ="center">P&T</td>
</tr>

<embed Height="1" Width="1" src="ar.mp3">
</html>


Ex : 1B                   RESUME USING ORDERED & UNORDERED LISTS
<html>
<!--body bgcolor="pink"-->
<body background="1.1.jpg">

<Marquee behavior="alternate">
<b><center><font face="Georgia" size="4" color="black">**********CURRICULUM VITAE**********</font></center></b>
</Marquee>

<p>
   <b>L MIDHUNA || lmidhuna@gmail.com || +91 9876543210 || lmidhuna.blogspot.com </b>  
 </p>
 <hr>

<b><font face="Georgia" size="3" color="Black">Career objective</b>
<ul>
   To have a challenging career that promotes my professional growth and to
   render quality service to the organisation to attain its goal
</ul>

<b><font face="Georgia" size="3">Scholastic Condition</font></b>
<ol>
  <li>Pursuing B.Tech Information Technology in KEC with CGPA <b>9.19</b></li>
  <li>Completed HSC in KVMHSS with an aggregate of <b>96%</b></li>
  <li>Completed SSLC in KVMHSS with an aggregate of <b>93%</b></li>
</ol>

<b><font face="Georgia" size="3">Academic Achievements</font></b>
<ol>
  <li>Awarded 50% scholarship for the academic performance during first year by Kongu Welfare Trust</li>
  <li>Secured School First in Chemistry in HSC examination</li>
  <li>Secured District Second in Geography and District Third in Mathematics in SSLC examination</li>
</ol>

<b><font face="Georgia" size="3">Computer Competence</font></b>
<ul type="circle">
  <li>Knowledge in C,C++</li>
  <li>Knowledge in Windows xp/7/8</li>
  <li>Knowledge in MySQl,MS Access</li>
  <li>Knowledge in Joomla, Adobe Photoshop CS </li>
</ul>

<b><font face="Georgia" size="3">Interested Field</font></b>
<ul type="arrow">
  <li> Database Management Systems </li>
</ul>

<b><font face="Georgia" size="3">Cocurricular Activities</font></b><br>

<b><font face="Georgia" size="3">Project</font></b><br>
<ul type="square">
  <li><b>Kongu Activities Forum</b> presented at Open House Exhibition in KEC
      <b>(First Prize)</b>
  </li>
</ul>

<b><font face="Georgia" size="3">Papers</font></b><br>
<ul type="circle">
  <li><b>Edrive-Automated Vehicles for Differently Abled</b> presented at Amrita University      <b>(Second Prize)</b>
  </li>
  <li><b>Solid Waste Management</b> presented at Johnsons Institute of Technology
      <b>(Third Prize)</b>
  </li>
</ul>

<b><font face="Georgia" size="3">Certification Courses</font></b>
<ul type="arrow">
<li>Web Designing using Joomla <b>(A grade)</b></li>
<li>Multimedia Course <b>(A grade)</b></li>
</ul>
<b><font face="Georgia" size="3">Membership Details</font></b>
<ul type="square">
<li>Member of CSI</li>
<li>Member of Energy & Environment Conservation Club</li>
</ul>

<b><font face="Georgia" size="3">Responsibility</font></b>
<ul type="circle">
  <li>Designed & maintaining the college activities website-
      <b>activity.kongu.edu</b>
  </li>
</ul>

<b><font face="Georgia" size="3">Extra Curricular Activities</font></b><br>
<ul type="arrow">
  <li><b>First Place</b> in <i>Web Designing</i> in Signin'12 </li>
  <li><b>Third Place</b> in <i>Talentia</i> in Envistas'12 </li>
  <li>Participated in <i>Poster Presentation</i> in Vivere'13 </li>
</ul>

<b><font face="Georgia" size="3">Hobbies</font></b>
<ol type="1.">
<li>Copoclephile</li>
<li>Reading books</li>
<li>Listening to music</li>
</ol>

<b><font face="Georgia" size="3">Personal Details</font></b>
<ul>
 <b>Name:</b>L.Midhuna<br>
 <b>D.O.B:</b>20.11.1992<br>
<b>Father's Name:</b>C.Lakshmanan<br>
<b>Mother's Name:</b>N.Saroja<br>
<b>Languages known:</b>Tamil,English<br>
<b>Address:</b>Perundurai<br>
</ul>

<b><font face="Georgia" size="3">Reference</font></b>
<ul>
  Dr.S.Varadhaganapathy M.E.,M.S.,Ph.D.,<br>
  Professor & Head<br>
  Department of IT<br>
  KEC,Perundurai-638052<br>
  Email id:svg@kongu.ac.in<br>
  Contact Number: +91 9876543211
</ul>

<p>
   <b>Place:</b>Perundurai<br>
   <b>Date:</b>27.06.2013
</p>
<p align="Right">
         <b><font face="Georgia" size="3">[L.MIDHUNA]</b>
</p>

<embed height="100" width="500" src="ar.mp3">

<video width="320" height="270" controls>
  <source src="1.mp4" type="video/mp4">
</body>
</html>


Ex : 2A                                                      TYPES OF CSS
css.html
<html>
<head>
<style>
body{ background-image: url(b6.4.jpg);
      background-repeat: tiling }
.pit { color:orange; font-size: 24pt; font-family:Bauhaus 93; font-weight:bold }
.para { font-family: Georgia; font-size: 15pt }
h1 {font-family: Monotype Corsiva; font-size: 30pt; text-align:left}
a.nodec {text-decoration:none}
a:hover {text-decoration:underline}
</style> </head>  <body> <br><br>
<marquee behavior="alternate">
<img src=w1.2.jpg alt="Web"> <img src=su4.2.jpg alt="Support"> <img src=c2.jpg alt="com">
  <p style= "text-align:center; font-size: 30pt; color:red; font-weight:bold">  @ one click   </p>
</marquee>
<p class="para">Hi...This page supports u in all domains.Make use of it..<br>
<br>Any Queries???????<a class="nodec" href="websupport@gmail.com">Ask us</a><br><br> We value ur Suggestions---<a class="nodec" href="websuppor t@gmail.com">Post us</a></p> <hr>
<h1>Tecnical Support</h1> <ul style="font-family:georgia; font-size:16pt">
    <li> C Support</li>    <li> Java Support</li> </ul>
<img src="su5.jpg" align="right"> <p class="pit">C SUPPORT</b><br>
<pre style="font-family: georgia; font-size: 13pt">
1.Write a c program without using any semicolon which output is: Hello word.
Solution: 1
void main()
{     if(printf("Hello world")){ }  }
Solution: 2
void main()
{     while(!printf("Hello world")){     } } </pre> <hr>
<p class="pit">JAVA SUPPORT</font></b><br>
<pre style="font-family: georgia; font-size: 13pt">
public class ArrayDemo {     public static void main(String[] args) {
int [] arr1,arr2; arr1=new int[1]; arr2=new int[2]; arr1[0]='\n'; arr2[0]='a';         System.out.print(arr2[0]%arr1[0]);     } }  </pre>
<h1>English Support</h1> <img src="a1.jpg">
<p style="font-size: 16pt; color:green; font-weight:bold">
Difference between 'Up-to-date' and 'updated'</p>
<p style="font-family:cambria; font-size: 16pt">

'Up-to-date' and 'updated' are closely related terms with distinct meanings. <br><br>
When you are 'up-to-date', it means that you are well aware of the current or present information about a thing or a situation. It is used an adjective.Example: The website gives an up-to-date information. <br><br>

'Updated' information indicates that there was a previous information or situation which has been made 'up-to-date' now. In other words, the available information was old hence new or current information has been added. The term 'Updated' is used as a verb.<br><br>

Example: All the PCs will be updated with the new software.Both these words are sometimes used interchangeably. </p><hr><audio src="1.mp3" controls></audio></body></html>

Ex : 2B                                 TOURISM WEBSITE USING CSS
<--div1.html>
<!DOCTYPE html>
<html>
<head>
<style>

div
{
position:relative;
left:20px;
width:1300px;
}

.d1
{

height:200px;
text-decoration:blink;
font-family:Algerian;
font-size:X-LARGE;
font-weight:bolder;
position:relative;
left:20px;
}

.d2
{
background-image: url(b6.4.jpg);
background-repeat: tiling;
background-color:white;
position:relative;
bottom:5px;
width:180px;
height:400px;
a.nodec {text-decoration:none};
a:hover {text-decoration:underline};
}


h2{
text-align:center;font-weight:bold;FONT-SIZE:46;
font-family=ahorani;color:'rgb(0,255,0)';
}

.d3
{
background-image:url('2.5.jpg');
background-color:white;
position:relative;
left:200px;
bottom:422px;
width:970px;
height:400px;
}

.d6
{
background-image: url(b6.4.jpg);
background-repeat: tiling;
background-color:white;
position:relative;
left:1170px;
bottom:823px;
width:150px;
height:400px;
}

.d8
{
background-color:purple;
position:relative;
bottom:850px;
width:1300px;
height:20px;
}

.d9{

position:relative;
bottom:850px;
width:130px;
height:20px;
}
</style>
</head>

<body>

<div class="d1">
<br>
<img src="t3.png" width="1300" height="180"/>
</div>

<div class="d2">
<br><br><h2>
<a class="nodec" href="home.html" >Home</a><br>
<a class="nodec" href="dest.html">Destination</a><br>
<a class="nodec" href="acc.html">Accomodation</a><br>
<a class="nodec" href="trans.html">Transport</a><br>
<a class="nodec" href="interest.html">Interests</a><br>
<a class="nodec" href="about.html">About- Switzerland</a><br>
<a href="ser.html">Service</a><br>
<a href="contac.html">Contact Us</a>
</h2>
</div>

<div class="d3">
<p><marquee>
<img src=ss1.11.png>
<img src=ss1.2.png>
<img src=ss1.31.png>
<img src=ss1.4.png>
<img src=ss1.5.png>
<img src=ss1.6.png>
</marquee></p>
<p style="font-weight:bold;font-size:20pt;text-align:center;
    font-family:lucida handwritng;color:red">
<blink>
Hotel Offer:Book any hotel in St.Moritz & Davos & get INR 1000/-
 offer
</blink>
</p>
</div>

<div class="d6">
<br><p style="align:center">
<img  src="f1.1.jpg" />
<br>
<br>
<a href="http://twitter.com" target="_blank"><img src=f5.2.jpg></a>
<a href="http://www.facebook.com" target="_blank"><img src=f9.2.jpg></a>
<br>
<a href="http://www.linkedin.com" target="_blank"><img src=f3.2.jpg></a>
<a href="http://plus.google.com" target="_blank"><img src=f13.2.jpg></a>
<br>
<a href="http://www.youtube.com" target="_blank"><img src=f11.1.jpg></a>
<a href="http://www.feedly.com" target="_blank"><img src=f7.2.jpg></a>
<p>
</div>

<div class="d8">
<p style="text-align:center;color:white">Copyrights@MySwitzerland.com</p>
</div>

<div class="d9">
<bgsound src="1.mp3" />
<audio src="1.mp3" controls></audio>
</body>
</html>

ßabout.html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sty.css">
</head>
<img src="about.png" width=1350 height=620>
</html>


ßacc.html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sty.css">
</head>
<body>
<p><a href="form1.html" target="_blank">Register Here</a>
<h1><blink>The most welcoming hotel of Swiss</blink></h1>
<br>
<img src="hat.jpg" width="500" height="300">
<br>
<h2>Hotel Lugano Dante Center</h2>
<p>
All guarantee excellent quality of sleep, thanks to extraordinarily efficient sound-proofing and the provision of the best mattresses on the market.
</p></body></html>

ßform1.html>
<html>
<body background =b6.6.jpg>
<font face = "CALIBRI" size = "5">
<marquee> <b><font color="blue" size="6" face="ar destine">SIGN UP HERE</FONT></marquee><br><br>
<i>* </i><B>First Name</B>    :<input type = "text" name = "firstname"> <br><br>
<B>Middle Name</B>    :<input type = "text" name = "firstname"> <br><br>
<B>  Last Name</B>    :<input type = "text" name = "lastname"> <br><br>
<i>* </i><B>User Name</B>                 :<input type = "text" name = "userid"> <br><br>
<i>* </i><B>  Password</B>      :<input type = "password" name = "pwd"> <br><br>
<i>* </i><B>  Re-Enter Password</B>      :<input type = "password" name = "pwd"> <br><br>
<B>Gender</B>: <br>
<input type = "radio" name = "gender" value = "male">Male<br>
<input type = "radio" name = "gender" value = "female">Female<br><br>
<i>* </i><B>Email Id</B> : <input type = "email" name = "mail"><br><br>
<i>* </i><B> Re-Enter Email Id</B> : <input type = "email" name = "mail"><br><br>
<B>DOB</B> : <input type = "date" name = "date" value = DATE()><br><br>
 <br>
<i>* </i><B>Membership Type</B> :
<select>
  <option value="Student">Student</option>
  <option value="Adult">Adult</option>
</select>
<br><br>
<b>Address</b><br>
<pre>      <textarea rows="8" cols="50"></textarea><br><br></pre>
<b>Country</B>    :<input type = "text" name = "firstname"> <br><br>
<b>Favourite Color:</b><input type="Color"><br><br>
<fieldset>
  <legend><b>Rate our website<b></legend>
  <input type = "radio" name = "gender" value = "male">Excellent<br>
<input type = "radio" name = "gender" value = "female">Good<br>
<input type = "radio" name = "gender" value = "female">Average<br>
<input type = "radio" name = "gender" value = "female">Poor<br>
 </fieldset>
<i>* Fields are mandatory</i><br>
<input type = "checkbox" name = "constraint" value = "agree"> I agree terms and conditions.<br> <br>
<a href = "REG.html"  target = "_blank">
<input type = "submit" value = "submit">
</a></B>
</form> </body> </html>


Ex : 3A                                               FORM
CODING
form.html
<html>
<body background =17.2.jpg>
<font face = "Old English Text MT" size = "8" color = "black">
<p align= "center"> REGISTRATION FORM <br><br> </font></p>
<font face = "Monotype Corsiva" size = "4" color = "black">
<b>First Name    :  <input type = "text" name = "firstname"> <br><br>
  Last Name    :  <input type = "text" name = "lastname"> <br><br>
User Name           : <input type = "text" name = "userid"> <br><br>
  Password      :  <input type = "password" name = "pwd"> <br><br>
Gender :  <br>
<input type = "radio" name = "gender" value = "male">Male
<input type = "radio" name = "gender" value = "female">Female<br><br>
Email Id :  <input type = "email" name = "mail"><br><br>
Date of birth:  <input type = "date" name = "date" value = DATE()><br><br>
Address     :  <input type = "text" name = "Address"> <br><br>
City          :  <input type = "text" name = "city"> <br><br>
State         :  <input type = "text" name = "state"> <br><br>
Color : <input type = "color"> <br><br>
Category : <br>
<input type = "radio" name = "staff" value = "staff">Staff
<input type = "radio" name = "student" value = "student">Student<br><br>
Company Name :
<select>
<option value="t1"> (none)</option value>
<optgroup label = Private>
            <option value="t2">CTS</option value>
            <option value="t3">TCS</option value>
</optgroup>
<optgroup label = Government>
            <option value="t4">BHEL</option value>
            <option value="t5">ISRO</option value>
</optgroup>
</select> <br><br><br>
<fieldset>
    <legend>Area of Interest :</legend>
    <input type = "checkbox" name = "constraint" value = "agree">Networks<br>
    <input type = "checkbox" name = "constraint" value = "agree">DBA<br>
    <input type = "checkbox" name = "constraint" value = "agree">Electronics<br>
  </fieldset>
<br><br>
To know about u...(if u wish)<br>
<pre>      <textarea rows="8" cols="60"></textarea><br><br></pre>
<input type = "checkbox" name = "constraint" value = "agree"> I agree terms and conditions..<br> <br>
<a href="submit1.html" target="_blank">
<input type = "Submit" value = "Submit">
</a> </font> </form></body>
</html>


Ex :3B            FORM VALIDATION USING REGULAR EXPRESSION

<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>Form Validation</title>
<meta name="keywords" content="example, JavaScript Form Validation, Sample registration form" />
<meta name="description" content="This document is an example of JavaScript Form Validation using a sample registration form. " />
<script>
function formValidation()
{
var uid = document.registration.userid;
var passid = document.registration.passid;
var uname = document.registration.username;
var uadd = document.registration.address;
var ucountry = document.registration.country;
var uzip = document.registration.zip;
var uemail = document.registration.email;
var umsex = document.registration.msex;
var ufsex = document.registration.fsex; if(userid_validation(uid,5,12))
{
if(passid_validation(passid,7,12))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(countryselect(ucountry))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
if(validsex(umsex,ufsex))
{}} }} }}}}
return false;
}
function userid_validation(uid,mx,my)
{
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len >= my || uid_len < mx)
{
alert("SSN should not be empty / length be between "+mx+" to "+my);
uid.focus();
return false;
}
return true;
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if(uname.value.match(letters))
{
return true;
}
else
{
alert('Name must have alphabet characters only');
uname.focus();
return false;
}
}
function alphanumeric(uadd)
{
var letters =/^[0-9a-zA-Z]+$/;
if(uadd.value.match(letters))
{
return true;
}
else
{
alert('Address must have alphanumeric characters only');
uadd.focus();
return false;
}
}
function countryselect(ucountry)
{
if(ucountry.value == "Default")
{
alert('Select your designation from the list');
ucountry.focus();
return false;
}
else
{
return true;
}
}

function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
return true;
}
else
{
alert("Please enter a valid email address!");
return false;
}
}

function validsex(umsex,ufsex)
{
x=0;
if(umsex.checked)
{
x++;
}
if(ufsex.checked)
{
x++;
}

if(x==0)
{
alert('Select Male/Female');
umsex.focus();
return false;
}
else
{
alert('Form Succesfully Submitted');
window.location.reload()
return true;
}
}

fuction my()
{
alert('Form Succesfully Submitted');
window.location.reload()
return true;
}
</script>
</head>

<body onLoad="document.registration.userid.focus();">
<i>
<h1><marquee>Sign up here</marquee></h1>
<form name='registration' onSubmit="return formValidation();">
<li><label for="userid"><br><b>SSN:</b></label></li>
<li><input type="text" name="userid" size="12" /></li>
<li><label for="username"><br><b>Name:</b></label></li>
<li><input type="text" name="username" size="50" /></li>
<li><label for="country"><br><b>Designation:</b></label></li>
<li><select name="country">
<option selected="" value="Default">(none)</option>
<option value="AF">Entrepreneur</option>
<option value="AL">Student</option>
<option value="DZ">Domestic Engineer</option>

</select></li>
<li><label for="email"><br><b>Email:</b></label></li>
<li><input type="text" name="email" size="50" /></li>
<li><label id="gender"><br><b>Sex:</b></label></li>
<li><input type="radio" name="sex" value="Male" /><span>Male</span></li>
<li><input type="radio" name="sex" value="Female" /><span>Female</span></li>
<li><label><br><b>Area of Interest(s):</b></label></li>
<li><input type="checkbox" name="en" value="en" checked /><span>DBMS</span></li>
<li><input type="checkbox" name="nonen" value="noen" /><span>Networks</span></li>
<li><input type="checkbox" name="nonen" value="noen" /><span>OS</span></li>
<li><input type="checkbox" name="nonen" value="noen" /><span>Web Designing</span></li>
<li><input type="checkbox" name="nonen" value="noen" /><span>Data Structures</span></li>
<li><label for="desc"><br><b>Achievements:</b></label></li>
<li><textarea name="desc" id="desc"></textarea></li>
<li><input type="submit" name="submit" value="submit" /></li>
</form>
</i>
</body>
</html>


Ex : 4A           THROW A DIE AND FIND THE NUMBER OF OCCURENCES
Coding
<!..Rolling a Die..!>
<html>
<body>
<title>Rolling A Die</title>
<script type="text/javascript">
var freq1=0;
var freq2=0;
var freq3=0;
var freq4=0;
var freq5=0;
var freq6=0;
var face;

for(var roll=1;roll<=30;roll++)
{
   face=Math.floor(1+Math.random()*6);
   document.writeln("face:" + face);

  switch(face)
  {
    case 1: ++freq1;break;
    case 2: ++freq2;break;
    case 3: ++freq3;break;
    case 4: ++freq4;break;
    case 5: ++freq5;break;
    case 6: ++freq6;break;
   }
  }
document.writeln("<table border = 2>");
document.writeln("<tr><th>Face</th>" + "<th>Frequency</th><tr>");
document.writeln("<tr><td>1</td>" + "<td>" + freq1 + "</td></tr>");
document.writeln("<tr><td>2</td>" + "<td>" + freq2 + "</td></tr>");
document.writeln("<tr><td>3</td>" + "<td>" + freq3 + "</td></tr>");
document.writeln("<tr><td>4</td>" + "<td>" + freq4 + "</td></tr>");
document.writeln("<tr><td>5</td>" + "<td>" + freq5 + "</td></tr>");
document.writeln("<tr><td>6</td>" + "<td>" + freq6 + "</td></tr>");

</script>
   <p><b>Click Refresh to run the script again</b></p>
</body>
</html>


Ex : 4B                          SIMULATION OF GAME
CODING
<html>
<head>
<title> SIMULATION OF GAME </title>
<style type="text/css">
table
{
text-align:right;
}
div.blue
{
color:blue;
}
</style>
<script type="text/javascript">
var WON=0;
var LOST=1;
var CONTINUE_ROLLING=2;
varfirstRoll=true;
varsumOfDice=0;
varmyPoint=0;
vargameStatus=CONTINUE_ROLLING;
function play()
{
var point=document.getElementById("pointfield");
varstatusDiv=document.getElementById("status");
if(firstRoll)
{
sumOfDice=rollDice();
switch(sumOfDice)
{
case 7:case 11:
gameStatus=WON;
point.value=" ";
break;
case 2: case 3: case 12:
gameStatus=WON;
point.value=" ";
break;
default:
gameStatus=CONTINUE_ROLLING;
myPoint=sumOfDice;
point.value=myPoint;
firstRoll=false;
}
}
else
{
sumOfDice=rollDice();
if(sumOfDice==myPoint)
gameStatus=WON;
else
if(sumOfDice==7)
gameStatus=LOST;
}
if(gameStatus==CONTINUE_ROLLING)
statusDiv.innerHTML="Roll again";
else
{
if(gameStatus==WON)
statusDiv.innerHTML="Player wins" +  "CLick Roll Dice to play again";
else
statusDiv.innerHTML="Player loses" +  "Click Roll Dice to play again";
firstRoll=true;
}
}
functionrollDice()
{
var die1;
var die2;
varworkSum;
die1= Math.floor(1+Math.random()*6);
die2=Math.floor(1+Math.random()*6);
workSum=die1+die2;
document.getElementById("die1field").value=die1;
document.getElementById("die2field").value=die2;
document.getElementById("sumfield").value=workSum;
returnworkSum;
}
</script>
</head>
<body bgcolor="azure">
<form action="">
<table>
<caption> Game Of Chance </caption>
<tr><td> Die 1</td>
<td><input id="die1field" type="text"/>
</td></tr>
<tr><td> Die 2</td>
<td><input id="die2field" type="text"/>
</td></tr>
<tr><td> Sum</td>
<td><input id="sumfield" type="text"/>
</td></tr>
<tr><td> Point</td>
<td><input id="pointfield" type="text"/>
</td></tr>
<tr><td /><td><input type="button" value="Roll Dice" onclick="play()" />
</td></tr>
</table>
<div id="status" class="blue">
Click the Roll Dice button to play</div>
</form>
</body>
</html>


Ex : 4C                           JAVASCRIPT OBJECTS
//String
<html>
<head>
<title>String Methods</title>
</head>
<body>
<script type="text/javascript">
  var s="GAYATHRI";
  var s1="KonGu college EnGG college";
  var s2="   bhuu   ";
  document.writeln("<b>" + s + "</b>"  + "<br>");
  document.writeln("<b>" + s1 + "</b>"  + "<br>");
  document.writeln("<b>" + s2 + "</b>"  + "<br>" + "<br>");

  document.writeln("Length:" + s.length + "<br>");
  document.writeln("Character at index 3 : " + s1.charAt(3) + "<br>");
  document.writeln("Chararcter Code at index 4:" + s.charCodeAt(4) + "<br>");
  document.writeln("Concatenated string:" +s.concat(s1) + "<br>");
  document.writeln(String.fromCharCode(98,97,108,108) + " contains char code 98 97 108 108" + "<br>");
  document.writeln("Index of college is " + s1.indexOf("college") + "<br>");
  document.writeln("Last Index of college is " + s1.lastIndexOf("college") + "<br>");
  document.writeln("Lowercase:" + s.toLowerCase() + "<br>");
  document.writeln("Uppercase:" + s1.toUpperCase() + "<br>");
  document.writeln("Substring:" + s1.substr(2,6) + "<br>");
  document.writeln("Substring method:" + s1.substring(2,5) + "<br>");
  document.writeln("Slice:" + s.slice(3,7) + "<br>");
  document.writeln("Split:" + s1.split("o") + "<br>");
  document.writeln("Value of:" +s.valueOf() + "<br>");
  document.writeln("Trim:" +s2.trim() + "<br>");
  document.writeln("Replace:" + s1.replace("EnGG","Arts") + "<br>");
   document.writeln("Search:" + s1.search("l") + "<br>");
</script>
</body>
</html>

Output
GAYATHRI
KonGu college EnGG college
bhuu 

Length:8
Character at index 3 : G
Chararcter Code at index 4:84
Concatenated string:GAYATHRIKonGu college EnGG college
ball contains char code 98 97 108 108
Index of college is 6
Last Index of college is 19
Lowercase:gayathri
Uppercase:KONGU COLLEGE ENGG COLLEGE
Substring:nGu co
Substring method:nGu
Slice:ATHR
Split:K,nGu c,llege EnGG c,llege
Value of:GAYATHRI
Trim:bhuu
Replace:KonGu college Arts college
Search:8

//Array
<html>
<body>
<script language="javascript">
var a=new Array(1,3,5,7,9);
var b=new Array(11,13,14,18,19);
var c=new Array(45,78,69,7,5);
var i=0;
document.write("<b>Array1 values:</b>");
for(i=0;i<a.length;i++)
{
   document.write(a[i] +"\t");
}
document.write("<br>");
document.write("<b>Array2 values:</b>" );
for(i=0;i<b.length;i++)
{
  document.write(b[i] +"\t");
}
document.write("<br>");
document.write("<b>Array3 values:</b>");
for(i=0;i<c.length;i++)
{
  document.write(c[i] +"\t");
}
document.write("<br>");
c=a.concat(b);
document.write("Length of concatenated array" +c.length +"<br>");
document.write("Concatenation:" +c+"<br>");
a.push(40,50);
document.write("Pushed array" +a+"<br>");
document.write("Popped value:" +a.pop()+"<br>");
document.write("Poped array:" +a+"<br>");
a.reverse();
document.write("Reversed array:" +a+"<br>");
c=a.shift();
document.write("Shifted array:" +c+"<br>");
document.write("Shift" +a+"<br>");
document.write("Sorted values" +a.sort()+"<br>");
document.write("String:" +a.toString()+"<br>");
var a1=new Array(10,20,30);
var b1=new Array("hai");
var c1 =a.join(b1);
document.write("Join:" +c1+"<br>");
</script>
</body>
</html>

Output
Array1 values:1 3 5 7 9
Array2 values:11 13 14 18 19
Array3 values:45 78 69 7 5
Length of concatenated array10
Concatenation:1,3,5,7,9,11,13,14,18,19
Pushed array1,3,5,7,9,40,50
Popped value:50
Poped array:1,3,5,7,9,40
Reversed array:40,9,7,5,3,1
Shifted array:40
Shift9,7,5,3,1
Sorted values1,3,5,7,9
String:1,3,5,7,9
Join:1hai3hai5hai7hai9

//Number
<html>
<body>
<script type="text/javascript">
var num= new Number("111.236589");
var n=35;
document.write("<b>Input values:</b>" + num +" and " + n +"<br>");
document.write("num.valueOf() is " + num.valueOf() + "<br>");
document.write("num.toPrecision() is " + num.toPrecision() + "<br>");
document.write("num.toPrecision(4) is " + num.toPrecision(4) + "<br>");
document.write("num.toFixed() is : " + num.toFixed(2) + "<br>");
document.write("(1.23e+20).toFixed(2) is:" + (1.23e+20).toFixed(2) + "<br>");
document.write("num.toExponential() is " + num.toExponential() + "<br>");
document.write("toString():" + n.toString() + "<br>");
document.write("Maximum value:" + Number.MAX_VALUE + "<br>");
document.write("Minimum value:" + Number.MIN_VALUE + "<br>");
</script>
</body>
</html>

Output
Input values:111.236589 and 35
num.valueOf() is 111.236589
num.toPrecision() is 111.236589
num.toPrecision(4) is 111.2
num.toFixed() is : 111.24
(1.23e+20).toFixed(2) is:123000000000000000000.00
num.toExponential() is 1.11236589e+2
toString():35
Maximum value:1.7976931348623157e+308
Minimum value:5e-324

//Date
<html>
<body>
<script type="text/javascript">
var d1=new Date();
var d2=new Date();

document.write("<b>Get Functions</b>" + "<br>");
document.write("Date:" +d1.getDate() +"<br>");
document.write("Day:" +d1.getDay() +"<br>");
document.write("Month:" +d1.getMonth() +"<br>");
document.write("Full year:" +d1.getFullYear() +"<br>");
document.write("Hours:" +d1.getHours() +"<br>");
document.write("Minutes:" +d1.getMinutes() +"<br>");
document.write("Seconds:" +d1.getSeconds() +"<br>");
document.write("Milliseconds:" +d1.getMilliseconds() +"<br>");
document.write("Time:" +d1.getTime() +"<br>");
document.write("Parse:" +Date.parse("February 21, 1993") +"<br>");
document.write("<b>Set Functions</b>" + "<br>");
d2.setDate(21);
document.write("Date:" +d2+"<br>");
d2.setMonth(1) ;
document.write("Month:" +d2+"<br>");
d2.setFullYear(1993);
document.write("Full year:" + d2+"<br>");
d2.setHours(21);
document.write("Hours:" +d2 +"<br>");
d2.setMinutes(35);
document.write("Minutes:" +d2+"<br>");
d2.setSeconds(45);
document.write("Seconds:" +d2 +"<br>");
d2.setMilliseconds(192);
document.write("Milliseconds:" +d2+"<br>");
d2.setTime(730233000000);
document.write("Time:" +d2+"<br>");
</script>
</body>
</html>

Output
Get Functions
Date:13
Day:2
Month:7
Full year:2013
Hours:22
Minutes:30
Seconds:21
Milliseconds:551
Time:1376413221551
Parse:730233000000
Set Functions
Date:Wed Aug 21 2013 22:30:21 GMT+0530 (India Standard Time)
Month:Thu Feb 21 2013 22:30:21 GMT+0530 (India Standard Time)
Full year:Sun Feb 21 1993 22:30:21 GMT+0530 (India Standard Time)
Hours:Sun Feb 21 1993 21:30:21 GMT+0530 (India Standard Time)
Minutes:Sun Feb 21 1993 21:35:21 GMT+0530 (India Standard Time)
Seconds:Sun Feb 21 1993 21:35:45 GMT+0530 (India Standard Time)
Milliseconds:Sun Feb 21 1993 21:35:45 GMT+0530 (India Standard Time)
Time:Sun Feb 21 1993 00:00:00 GMT+0530 (India Standard Time)


Ex : 4D                  JAVASCRIPT PROGRAM USING COLLECTIONS
CODING
<html>
<head>
<script type="text/javascript">
var currentnode;
function cn()
{
var id=document.getElementById("5").value;
var target=document.getElementById(id);
if(target)
switchTo(target);
}
function switchTo(nnode)
{
//currentnode.className="";
currentnode=nnode;
currentnode.className=currentnode.id+"highlighted";
document.getElementById(55).innerHTML=currentnode.className;
document.getElementById(5).value=currentnode.id+"_"+currentnode.innerHTML;
}
</script>
</head>
<body >
<h1 id="1" >header 1</h1>
<p id="2">para 1</p> <p id="3">para2</p> <p id="4">para3</p>
<p id="55">temp</p>
<input type="text" id="5" value="1" />
<input type="button" value="click" onclick="cn()" />
</body>
</html>
CODING
<html>
<head>
<script type="text/javascript">
var currentnode;//={"className":"","data-role":"info"};
var idc=0;
var id=0;
function cn()       {
 id=document.getElementById("5").value;
var target=document.getElementById(id);   
if(target)
switchTo(target);       }
function switchTo(nnode)      { 
//currentnode.className="";
currentnode=nnode;
currentnode.className=currentnode.id+"highlighted";
document.getElementById("5").value=currentnode.id+"_"+currentnode.innerHTML;       }
function insert()     {
var nnode=createNewNode(document.getElementById("6").value);
currentnode.parentNode.insertBefore(nnode,currentnode);       }
function createNewNode(text)         {
var newNode=document.createElement("p");
++idc;
newNode.id="new"+idc;
text="["+newNode.id+"]"+text;
var textnode=document.createTextNode(text);
newNode.appendChild(textnode);
return newNode;           }
</script>  </head>
<body>
<h1 id="1" >header  /</h1>
<p id="2">para 1/</p>
<p id="3">para2</p>
<p id="4">par3/</p>
<p id="55"></p>
<input type="text" id="5" value=" enter the position of text to be inserted" />
<input type="button" value="click" onclick="cn()" /> <br/>
<input type="text" id="6" value="enter the content to be  inserted" />
<input type="button" value="insertbefore" onclick="insert()" />
<p id="9"></p>
</body>
</html>

CODING
<html>
<head>
<script type="text/javascript">
var currentnode;
var idc=0;
function cn()     {
var id=document.getElementById("5").value;
var target=document.getElementById(id);
if(target)
switchTo(target);      }
function app()        {
var nnode=cnn(document.getElementById("6").value);
currentnode.appendChild(nnode);
if(nnode)
switchTo(nnode);       }
function cnn(text)        {
var nn=document.createElement("p");
++idc;
nn.id="new"+idc;
text="["+nn.id+"]"+text;
nn.appendChild(document.createTextNode(text));
return nn;          }
function switchTo(nnode)         {
currentnode.className="";
currentnode=nnode;
currentnode.className=currentnode.id+"highlighted";
document.getElementById("5").value=currentnode.id+"_"+currentnode.innerHTML;        }
</script>  </head>
<body onload="currentnode=document.getElementById('1')">
<h1 id="1" class="highlighted">heading1/</h1>
<p id="2">para1/</p>
<p id="3">para2/</p>
<p id="4">para3/</p>
<input type="text" id="5" value="1" />
<input type="button" value="click" onclick="cn()" />  <br/>
<input type="text" id="6" value="ddgdfg" />
<input type="button" value="append" onclick="app()" />
<p id="9"></p>
</body>
</html>

CODING
<html>
<head>
<script type="text/javascript">
var currentnode;
var idc=0;
function cn()      {
var id=document.getElementById("5").value;
var target=document.getElementById(id);
if(target)
switchTo(target);      }
function rc()      {
var nnode=cnn(document.getElementById("6").value);
currentnode.parentNode.replaceChild(nnode,currentnode)
if(nnode)
switchTo(nnode);      }
function cnn(text)      {
var nn=document.createElement("p");
++idc;
nn.id="new"+idc;
text="["+nn.id+"]"+text;
nn.appendChild(document.createTextNode(text));
return nn;      }
function switchTo(nnode)      {
currentnode.className="";
currentnode=nnode;
currentnode.className=currentnode.id+"highlighted";
document.getElementById("5").value=currentnode.id+"_"+currentnode.innerHTML;      }
</script>  </head>
<body onload="currentnode=document.getElementById('1')">
<h1 id="1" class="highlighted">feerteter ggdfgd dfgd fdv fgdg/</h1>
<p id="2">ijish fhhara kjdgjsdjgh jkdgjhdf/</p>
<p id="3">sdsdd gfdf  dfgd  df gd g dfgdg/</p>
<p id="4">sdfd fghf oupio pytouptoyu ghfh/</p>
<input type="text" id="5" value="1" />
<input type="button" value="click" onclick="cn()" /> <br/>
<input type="text" id="6" value="ddgdfg" />
<input type="button" value="replace" onclick="rc()" />
<p id="9"></p>
</body>
</html>

CODING
<html>
<head>
<script type="text/javascript">
var currentnode;
var idc=0;
function cn()
{
var id=document.getElementById("5").value;
var target=document.getElementById(id);
if(target)
switchTo(target);
}
function rm()
{
var onode=currentnode;
if(onode)
switchTo(onode.parentNode);
currentnode.removeChild(onode);
}
function switchTo(nnode)
{
currentnode.className="";
currentnode=nnode;
currentnode.className=currentnode.id+"highlighted";
document.getElementById("5").value=currentnode.id+"_"+currentnode.innerHTML;
}
</script>
</head>
<body onload="currentnode=document.getElementById('1')">
<h1 id="1" class="highlighted">heading1/</h1>
<p id="2">para1/</p>
<p id="3">para2/</p>
<p id="4">para3/</p>
<input type="text" id="5" value="1" />
<input type="button" value="click" onclick="cn()" />
<br/>
<input type="button" value="remove" onclick="rm()" />
<p id="9"></p>
</body>
</html>

CODING
<html>
<head>
<script type="text/javascript">
var currentnode;
var idc=0;
function cn()
{
var id=document.getElementById("5").value;
var target=document.getElementById(id);
if(target)
switchTo(target);
}
function parents()
{
var target=currentnode.parentNode;
if(target!=document.body)
{
document.getElementById("9").innerHTML=target;
}
switchTo(target);
}
function switchTo(nnode)
{
currentnode.className="";
currentnode=nnode;
currentnode.className=currentnode.id+"highlighted";
document.getElementById("5").value=currentnode.id;
}
</script>  </head>
<body onload="currentnode=document.getElementById('1')">
<h1 id="1" class="highlighted">heading1/</h1>
<p id="2">para1/</p>
<p id="3">para2/</p>
<ul id="parentlist">
<li id="10">list1</li>
<li id="11">list2</li>  </ul>
<input type="text" id="5" value="1" />
<input type="button" value="click" onclick="cn()" /> <br/>
<input type="button" value="parent" onclick="parents()" />
<p id="9"></p>
</body>
</html>

CODING
 <html >
 <head>
 <title>Using Links Collection</title>
 <script type = "text/javascript">
 function processlinks()
 {
 var linkslist = document.links;// get the document's links
 var contents = "Links in this page:\n<br />| ";
 // concatenate each link to contents
 for ( var i = 0; i <linkslist.length ; i++ )
 {
var currentLink = linkslist[ i ];
contents += "<span class = 'link'>" +currentLink.innerHTML.link( currentLink.href ) +"</span> | ";
 } // end for
 document.getElementById( "links" ).innerHTML = contents;
 } // end function processlinks
 </script>
 </head>
 <body >
 <h1>Deitel Resource Centers</h1>
 <p><a href = "http://www.deitel.com/">Deitel's website</a>
contains a rapidly growing
 <a href = "http://www.deitel.com/ResourceCenters.html">list of Resource Centers</a>
on a wide range of topics. Many Resource centers related to topics covered in this book,
 <a href = "http://www.deitel.com/iw3htp4">Internet and World Wide
 Web How to Program, 4th Edition</a>.
 We have Resouce Centers on
 <a href = "http://www.deitel.com/Web2.0">Web 2.0</a>,
 <a href = "http://www.deitel.com/Firefox">Firefox</a>
and
 <a href = "http://www.deitel.com/IE7">Internet Explorer 7</a>,
 <a href = "http://www.deitel.com/XHTML">XHTML</a>, and
 <a href = "http://www.deitel.com/JavaScript">JavaScript</a>.
 Watch the list of Deitel Resource Centers for related new Resource Centers.</p>
<input type="button" value="click" onclick="processlinks()">
<p id = "links" class = "links"></p>
 </body>
</html>

CODING
<html>
<head>
<script type="text/javascript">
var it=Array(10);
var cn=Array(10);
for(var i=0;i<10;i++)
cn[i]=0;
ic=0;
function cal(itm)      {
it[ic]=itm;
cn[ic]++;
document.write("Hello……");  
return;      }
</script>  </head>
<body >
<p onclick="cal('sdfs')">Click Here</p>
<p>Hai……</p>
</body>
</html>
                                                   
CODING
<html>
 <head>
<title>Dynamic Styles</title>
<script type = "text/javascript">
 function start()
 {
var inputColor = prompt( "Enter a color name for the background of this page", "" );
document.body.style.backgroundColor = inputColor;
 } // end function start
 </script>
 </head>
 <body id = "body" bgcolor="pink" onload = "start()">
 <p>Welcome to our website!</p>
 </body>
 </html>

CODING
<html >
 <head>
 <title>Deitel Book Cover Viewer</title>
 <style type = "text/css">
div      {
display:inline;      }
 .imgCover { height: 300px }
 img { border: 1px solid black }
 </style>
 <script type = "text/javascript">
 <!--
 var interval = null; // keeps track of the interval
 var speed = 6; // determines the speed of the animation
 var count = 0; // size of the image during the animation
 // called repeatedly to animate the book cover
 function run()      {
 count += speed;
 // stop the animation when the image is large enough
 if ( count >= 300 )      {
 window.clearInterval( interval );
interval = null;      } // end if
 var bigImage = document.getElementById( "imgCover" );
 bigImage.style.width = .9656 * count + "px";
 bigImage.style.height = count + "px";      } // end function run
 // inserts the proper image into the main image area and
 // begins the animation
 function display( imgfile )      {
 if ( interval )
 return;
 var bigImage = document.getElementById( "imgCover" );
 var newNode = document.createElement( "img" );
 newNode.id = "imgCover";
 newNode.src = imgfile;
 newNode.alt = "Large image";
 newNode.className = "imgCover";
 newNode.style.width = "0px";
 newNode.style.height = "0px";
 bigImage.parentNode.replaceChild( newNode, bigImage );
 count = 0; // start the image at size 0
interval = window.setInterval( "run()", 10 ); // animate      } // end function display
 </script>   </head>
 <body>
 <div id = "thumbs" class = "thumbs" >
 <img src = "2.jpg" alt = "2" width="200" height="100"
 onclick = "display( '2.jpg' )" />
 <img src = "3.jpg" alt = "3" width="200" height="100"
 onclick = "display( '3.jpg' )" />
 <img src = "4.jpg" alt = "4" width="200" height="100"
 onclick = "display( '8.jpg' )" /><br>
 <img src = "5.jpg" alt = "5" width="200" height="100"
 onclick = "display( '5.jpg' )" />
 <img src = "1.jpg" alt = "6" width="200" height="100"
 onclick = "display( '6.jpg' )" />
 <img src = "7.jpg" alt = "6" width="200" height="100"
 onclick = "display( '7.jpg' )" />
 </div> <br>
<div id = "mainimg" class = "mainimg">
 <img id = "imgCover" src = "6.jpg" alt = "Full cover image" class = "imgCover" />
 </div>
 </body>
</html>


Ex : 4E                             EVENTS AND EVENT BUBBLING
//Events
<html>
<body onload="checkcookies()">
<h1 onclick="changetxt(this)">Click on this text</h1>
Enter any text <input type="text" id="txt1" onchange="fun()">
<p>This changes the text to uppercase when you leave the input field</p>

<p>Click on the button to display date</p>
<button onclick="displaydate()">Click</button>
<script>
function checkcookies()
{
  if(navigator.cookiesEnables==true)
    {
      alert("Cookies are enabled");
     }
  else
    {
      alert("Cookies are not enabled");
     }
}
function changetxt(id)
{
  id.innerHTML="Information Technology";
}
function fun()
{
  var x=document.getElementById("txt1");
  x.value=x.value.toUpperCase();
}
 function displaydate()
{
  document.getElementById("demo").innerHTML=Date();
}
</script>
<h1 id="demo"></h1>
</body>
</html>

//Event Bubbling

<!DOCTYPE HTML>
<html>
<body>
<link type="text/css" rel="stylesheet" href="example.css">
           
<div class="d1" onclick="highlight(this)">1
    <div class="d2" onclick="highlight(this)">2
        <div class="d3" onclick="highlight(this)">3
        </div>
    </div>
</div>

<script>
function highlight(elem) {
    elem.style.backgroundColor='yellow'
    alert(elem.className)
    elem.style.backgroundColor = ''
}
</script>

</body>
</html>


Ex : 5A                        FORM VALIDATION USING PHP
CODING
<!DOCTYPE HTML>
<html> <head> <style>
.error {color: #FF0000; font-weight:bolder; font-size:x-large;}
label { font-weight:bolder; }
#d1 { background-color:pink; }
</style> </head>
<body> <div id="d1">
<?php
// define variables and set to empty values
$nameErr=$emailErr = $genderErr = $passwordErr = $pass1Err =$mobileerr ="";
$currenterr = $chkerr="";
$name= $email = $gender= $password=$pass1=$birth=$mobile=$current=$chk=$status="";
$st=0;
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["name"]))
{$nameErr = "Name is required";
$st=1;
}
else
{
$name = ($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name))
{
$st=1;
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"]))
{$emailErr = "username is required";
$st=1;
}
else
{
$email = ($_POST["email"]);
// check if e-mail address syntax is valid
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
$emailErr = "Invalid email format";
$st=1;
}
else
{
if(preg_match("/sree@gmail.com/",$email))
{
$emailErr="User name already exists try again with any other username";
$st=1;
}
}
}

if (empty($_POST["password"]))
{
$passwordErr = "password Required";
$st=1;
}
else
{
$password =($_POST["password"]);
// check if it contains minimum char
if (!preg_match("/^[a-zA-Z0-9]/",$password))
{$st=1;
$passwordErr ="does not match the pattern";
}
else
{
if(strlen($password)<8)
{
$st=1;
$passwordErr="password too short(minimum 8 characters)";
}
}
}
if (empty($_POST["pass"]))
{$pass1Err= "Retype your password";
$st=1;
}
else
{
$pass1 = ($_POST["pass"]);
if (!preg_match("/$password/",$pass1))
{ $st=1;
$pass1Err ="password does not match";
}
}
if (empty($_POST["gender"]))
{$genderErr = "Gender is required";
$st=1;}
else
{$gender = ($_POST["gender"]);
}
}
if(empty($_POST["phno"]))
{$mobileerr="";
$st=1;
}
else
{
$mobile=($_POST["phno"]);
if(preg_match("/^[0-9]/",$mobile))
{
if(strlen($mobile)!=10)
{
$st=1;
$mobileerr="PHONE number must have 10 numbers";
}
}
else
{
$mobileerr="Phone number invalid";
$st=1;
}
}
if (empty($_POST["current"]))
{$currenterr = "";
}
else
{
$current = ($_POST["current"]);
// check if e-mail address syntax is valid
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$current))
{
$currenterr = "Invalid email Id";
$st=1;
}
}
if (isset($_POST["agree"]))
{
$chkerr="";
$chk = ($_POST["agree"]);
}
else
{
$chkerr= "Inorder to use our services,you must Agree to the terms of services";
$st=1;
}
if($st==0)
{
$status="ACCOUNT CREATED SUCEESFULLY";
}
if($status!="")
{
echo "<script type = 'text/javascript'>\n";
echo "alert('ACCOUNT CREATED SUCCESFULLY');\n";
echo "</script>";
exit;
}
?>
<h2>CREATE NEW ACCOUNT </h2>
<pre>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php $_SERVER["PHP_SELF"];?>">
<label>Name:</label>                         <input type="text" name="name"> <span class="error">* <?php echo $nameErr;?></span>  <br>
<label>Choose your username:</label> <input type="text" name="email" placeholder="@gmail.com"> <span class="error">* <?php echo $emailErr;?></span><br>
<label>create password</label>         <input type="password" name="password"> <span class="error">*<?php echo $passwordErr;?></span>  <br>
<label>confirm your password</label>          <input type="password" name="pass"> <span class="error">*<?php echo $pass1Err;?></span>  <br>
<label>Gender:</label>
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male  <span class="error">* <?php echo $genderErr;?></span>    <br>
<label>Mobile number</label>                       <input type="text" name="phno" value=""><span class="error"><?php echo $mobileerr;?></span> <br>
<label>CURRENT EMAIL ADDRESS</label> <input type="text" name="current"><span class="error"><?php echo $currenterr;?></span> <br>
<input type="checkbox" name="agree" value="I agree to the terms of services and privacy policy">I agree to the terms of services and privacy policy</input><span class="error">*</span><span class="error"><?php echo $chkerr;?></span> <br>
<input type="submit" name="submit" value="create account">
</form> </pre> </div> </body> </html>


Ex : 5B                            AIRLINE RESERVATION SYSTEM
Coding
//Home page
<html>
<head>
<style>
#d1                                                                                                                       
{
background-color:#ccebd6;
width:700px;
height:450px;
position:relative;
left:200px;
text-align:center;
}
</style>
</head>
<body>
<div id="d1">
<h1>AIR LINE RESERVATION SYSTEM</h1>
<form action="book.php" method="post">
<input style="background-color:green;color:white;font-size:larger;" type="submit" value="book tickets" name="book"/>
</form><br/>
<form action="cancel.php" method="post">
<input style="background-color:red;color:white;font-size:larger;" type="submit" value="cancel tickets" name="cancel"/>
</form><br/>
<form action="view1.php" method="post">
<input style="background-color:green;color:white;font-size:larger;" type="submit" value="check availability" name="check"/>
</form>
</div>
</body>
</html>

//Booking
<html>
<head>
<style>
#d1
{
background-color:#ccebd6;
width:700px;
height:450px;
position:relative;
left:200px;
}
pre
{
position:relative;
left:100px;
font-size:larger;
font-weight:bolder;
}
</style>
</head>
<?php
$st="";
$s=0;
$t1=1000;
if (empty($_POST["EmailId"])||empty($_POST["Name"])||empty($_POST["contactno"])||empty($_POST["travel"])||empty($_POST["flight"]))
{
$st="all fields required";
}
else
{
$con=mysqli_connect("","root","","bk");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$con1=mysqli_connect("","root","","avail");
$res = mysqli_query($con1,"SELECT * FROM available");
while($row = mysqli_fetch_array($res))
  {
if(($_POST["flight"]==$row['flight'])&&($_POST["travel"]<=$row['tickets_available']))
{
$in="INSERT INTO tickets VALUES ('','$_POST[Name]','$_POST[contactno]','$_POST[travel]','$_POST[flight]','$_POST[EmailId]')";
mysqli_query($con,$in);
$t=$row['tickets_available']-$_POST["travel"];
mysqli_query($con1,"UPDATE available SET tickets_available='$t' WHERE  flight='$_POST[flight]'");
echo "<script>";
echo "alert('Booked Sucessfully')";
echo "</script>";
$s=1;
break;
}
}
if($s!=1)
{
echo "<script type='text/javascript'>";
echo "alert('Ticket not available')";
echo "</script>";
}
}
?>
<body>
<div id="d1">
<h2 align="center">BOOKING</h2>
<pre>
<form action="<?php $_SERVER["PHP_SELF"];?>" method="post">
EmailId                       <input type="text" name="EmailId"><br/>
Name               <input type="text" name="Name"><br/>
Contactno       <input type="text" name="contactno"><br/>
Travellers         <input type="text" name="travel" value="1"><br/>
flight               <input type="text" name="flight"><br/>
<p><?php echo $st;?></p>
<input style="background-color:green;" type="submit" name="book" value="bookticktes"><br/>
</form></pre>
<form style="position:relative;left:100px;" action="view.php" method="post">
<input style="background-color:red;" type="submit" name="book" value="check availabilty"><br/>
</form>
</div>
</body>
</html>

//Check availability
<?php
$con=mysqli_connect("","root","","avail");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$result = mysqli_query($con,"SELECT * FROM available");
echo "<h1 align='center' style='color:purple;'>AVAILABITY OF SEATS</h1>";
echo "<table border='2' align='center' width='1000' height='300' style='border-collapse:collapse;text-align:center;'>
<tr>
<th>Flight</th>
<th>Name</th>
<th>source</th>
<th>destination</th>
<th>departure time</th>
<th>Arrival Time</th>
<th>Date</th>
<th>Availble Seats</th>
</tr>";
while($row = mysqli_fetch_array($result))
  {
echo "<tr>";
echo "<td>".  $row['flight'] ."</td>"."<td>". $row['name']."</td>"."<td>".$row['source']."</td>"."<td>".$row['destination']."</td>"."<td>".$row['dept']."</td>"."<td>".$row['arr']."</td>"."<td>".$row['date']."</td>"."<td>".$row['tickets_available']."</td>";
echo "</tr>";
    }
echo "</table>";
mysqli_close($con);
?>

//Cancellation
<html>
<head>
<style>
#d1
{
background-color:#ccebd6;
width:700px; height:450px;
position:relative;
left:200px;
}
pre
{
position:relative;
left:100px;
font-size:larger;
font-weight:bolder;
}
</style>
</head>
<?php
$st="";
$s=0;
if (empty($_POST["reservation"])||empty($_POST["flight"])||empty($_POST["emailid"])||empty($_POST["seats"]))
{
$st="all fields required";
}
else
{
$con=mysqli_connect("","root","","bk");
$con1=mysqli_connect("","root","","avail");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$res = mysqli_query($con,"SELECT * FROM tickets");
while($row = mysqli_fetch_array($res))
  {
if(($_POST["reservation"]==$row['reservation_no'])&&($_POST["flight"]==$row['flight'])&&($_POST["emailid"]==$row['email_id']))
{
if($_POST["seats"]==$row['travel'])
{
mysqli_query($con,"DELETE FROM tickets WHERE reservation_no='$_POST[reservation]' AND email_id='$_POST[emailid]'");
//$re1=mysqli_query($con1,"SELECT tickets_available FROM available WHERE flight='$_POST[flight]'");
//$t2=$_POST["seats"]+$re1;
mysqli_query($con1,"UPDATE available SET tickets_available=tickets_available+'$_POST[seats]' WHERE flight='$_POST[flight]'");
$s=1;
echo "<script>";
echo "alert('Your ticket has been canceled')";
echo "</script>";
}
else if($_POST["seats"]<$row['travel'])
{
$t1=$row['travel']-$_POST["seats"];
mysqli_query($con,"UPDATE tickets SET travel='$t1' WHERE reservation_no='$_POST[reservation]' AND email_id='$_POST[emailid]'");
mysqli_query($con1,"UPDATE available SET tickets_available=tickets_available+'$_POST[seats]' WHERE flight='$_POST[flight]'");
$s=1;
echo "<script>";
echo "alert('Your ticket has been canceled')";
echo "</script>";
}
}
}
if($s!=1)
{
echo "<script>";
echo "alert('The information provided by you is not correct')";
echo "</script>";
}
}
?>
<body>
<div id="d1">
<h2 align="center">CANCELLATION</h2>
<pre>
<form action="<?php $_SERVER["PHP_SELF"];?>" method="post"><br/>
Reservation No           <input type="text" name="reservation"><br/>
Flight               <input type="text" name="flight"><br/>
email Id                       <input type="text" name="emailid"><br/>
No of seats                  <input type="text" name="seats"><br/>
<input style="background-color:green;" type="submit" value="cancel" name="cancel"><br/>
<p><?php echo $st;?></p>
</form> </pre>
</div>
</body>
</html>
//Check availability
<html>
<head>
<style>
#d1
{
background-color:#ccebd6;
width:1000px;

position:relative;
left:200px;
}
pre
{
position:relative;
left:100px;
font-size:larger;
font-weight:bolder;
}
</style>
</head>
<body>
<body>
<div id="d1">
<h2 align="center">CHECK AVAILABILITY</h2>
<pre>
<form action="<?php $_SERVER["PHP_SELF"];?>" method="post"><br/>
Enter date to view availability            <input type="date" name="dt"><br/>
<input style="background-color:green;" type="submit" name="check" value="check availability"><br/>
</form>
</pre>
<?php
if (empty($_POST["dt"]))
{
$st="all fields required";
}
else
{
$con=mysqli_connect("","root","","avail");
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$result = mysqli_query($con,"SELECT * FROM available");
echo "<h1 align='center' style='color:purple;'>AVAILABITY OF SEATS</h1>";
echo "<table border='2' align='center' width='1000' height='300' style='border-collapse:collapse;text-align:center;'>
<tr>
<th>Flight</th>
<th>Name</th>
<th>source</th>
<th>destination</th>
<th>departure time</th>
<th>Arrival Time</th>
<th>Date</th>
<th>Available Seats</th>
</tr>";
while($row = mysqli_fetch_array($result))
  {
if($_POST["dt"]==$row['date'])
{
echo "<tr>";
echo "<td>".  $row['flight'] ."</td>"."<td>". $row['name']."</td>"."<td>".$row['source']."</td>"."<td>".$row['destination']."</td>"."<td>".$row['dept']."</td>"."<td>".$row['arr']."</td>"."<td>".$row['date']."</td>"."<td>".$row['tickets_available']."</td>";
echo "</tr>";
    }
}
echo "</table>";
mysqli_close($con);
}
?>
</div>
</body>
</html>


Ex : 6A                                Form Validation & Email Verification   
CODING
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 253px; position: absolute;
            top: 70px"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Style="z-index: 101; left: 186px; position: absolute;
            top: 310px" Text="Submit" Font-Bold="False" Font-Size="Large" />
        <asp:Label ID="Label1" runat="server" Font-Size="Large" Style="z-index: 102; left: 61px;
            position: absolute; top: 66px" Text="Name" Width="132px"></asp:Label>
        <asp:TextBox ID="TextBox2" runat="server" Style="z-index: 103; left: 251px; position: absolute;
            top: 108px"></asp:TextBox>
        <asp:Label ID="Label2" runat="server" Font-Size="Large" Style="z-index: 104; left: 62px;
            position: absolute; top: 145px" Text="Password" Width="135px"></asp:Label>
        <asp:Label ID="Label3" runat="server" Font-Size="Large" Style="z-index: 105; left: 60px;
            position: absolute; top: 107px" Text="Email ID" Width="134px"></asp:Label>
        <asp:TextBox ID="TextBox3" runat="server" Style="z-index: 106; left: 252px; position: absolute;
            top: 147px" TextMode="Password"></asp:TextBox>
        <asp:Label ID="Label4" runat="server" Font-Size="Large" Style="z-index: 107; left: 61px;
            position: absolute; top: 232px" Text="Age" Width="135px"></asp:Label>
        <asp:Label ID="Label5" runat="server" Font-Size="Large" Style="z-index: 108; left: 59px;
            position: absolute; top: 186px" Text="Confirm Password" Width="139px"></asp:Label>
        <asp:TextBox ID="TextBox4" runat="server" Style="z-index: 109; left: 249px; position: absolute;
            top: 235px"></asp:TextBox>
        <asp:TextBox ID="TextBox5" runat="server" Style="z-index: 110; left: 251px; position: absolute;
            top: 187px" TextMode="Password"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
            ErrorMessage="Name is Mandatory" ForeColor="DeepPink" Style="z-index: 111; left: 421px;
            position: absolute; top: 72px" Width="137px"></asp:RequiredFieldValidator>
        &nbsp;
        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox3"
            ControlToValidate="TextBox5" ErrorMessage="Password doesnot  match. Re-type your Password"
            Style="z-index: 113; left: 421px; position: absolute; top: 153px"></asp:CompareValidator>
        <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox4"
            ErrorMessage="Age must be above 10 & below 60" MaximumValue="60" MinimumValue="10"
            Style="z-index: 114; left: 416px; position: absolute; top: 224px"></asp:RangeValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox3"
            ErrorMessage="Password Field Mandatory" Style="z-index: 115; left: 502px; position: absolute;
            top: 198px" Width="195px"></asp:RequiredFieldValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox2"
            ErrorMessage="Email id  is Mandatory" Style="z-index: 116; left: 423px; position: absolute;
            top: 111px" Width="200px"></asp:RequiredFieldValidator>
        &nbsp;
        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox5"
            ErrorMessage="Confirm Password Field Mandatory" Style="z-index: 118; left: 416px;
            position: absolute; top: 187px"></asp:RequiredFieldValidator>
   
    </div>
    </form>
</body>
</html>

Ex : 6B                                             VIEWS OF DATABASE

CODING:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}


Ex : 6C                                      DATABASE QUERYING

CODING:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page
{
    OleDbConnection con = new OleDbConnection();
    OleDbCommand com = new OleDbCommand();
    OleDbDataReader res;
    protected void Page_Load(object sender, EventArgs e)
    {
        con.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;Data source=C:\\Users\\Indhu L\\Documents\\1.Kongu Engineering College\\2.7thsem\\wt lab\\asp.net\\database querying\\WebSite16\\App_Data\\db.mdb";
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            com.CommandText = "select * from table1 where ID='"+ TextBox4.Text +"'";
            com.Connection = con;
            res = com.ExecuteReader();
            while (res.Read())
            {
                TextBox1.Text = res.GetString(0);
                TextBox2.Text = res.GetString(1);
                TextBox3.Text = res.GetString(2);
            }
            res.Close();
            con.Close();
        }
        catch (Exception e1)
        {
            Label4.Text = e1.Message;
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            com.CommandText = "insert into table1 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')";
            com.Connection = con;
            com.ExecuteNonQuery();
        }
        catch (Exception e2)
        {
            Label4.Text = e2.Message;
        }
        con.Close();

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            com.CommandText = "delete from table1 where ID='" + TextBox4.Text + "'";
            com.Connection = con;
            com.ExecuteNonQuery();
        }
        catch (Exception e3)
        {
            Label4.Text = e3.Message;
        }
        con.Close();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        try
        {
            con.Open();
            com.CommandText = "update table1 set name='"+TextBox2.Text+"',marks='"+TextBox3.Text+"'where ID='"+TextBox1.Text+"'";
            com.Connection = con;
            com.ExecuteNonQuery();
        }
        catch (Exception e3)
        {
            Label4.Text = e3.Message;
        }
        con.Close();
    }
}


Ex : 6D                                    WEB SERVICES
CODING
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]
    public int Rs_to_Dollar(int rs)
    {
        return (rs*65);
    }
        [WebMethod]
    public double Dollar_to_Rs(int d)
    {
        return (d/63.38);
    }
    [WebMethod]
    public double Cel_to_Faren(int c)
    {
        return ((c*9/5)+32);
    }
    [WebMethod]
    public double Faren_to_Cel(int f)
    {
        return (f-32)*5/9;
    }
    [WebMethod]
    public double Circle_Area(int r)
    {
        return (3.14*r*r);
    }
        [WebMethod]
    public double Circle_Circumference(int r)
    {
        return (3.14*r*2);
    }
}


Ex : 7A                           CREATION OF DTD FOR BOOK STORE
<!DOCTYPE bookstore [
<!ELEMENT bookstore (book+)>
<!ELEMENT book (title,author,ISBN,publisher,edition,price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>
]>
<bookstore>
            <book>
                        <title>web programming</title>
                        <author>chrisbates</author>
                        <ISBN>123-456-789</ISBN>
                        <publisher>wiley</publisher>
                        <edition>3</edition>
                        <price>350</price>
            </book>
            <book>
                        <title>internet worldwideweb</title>
                        <author>ditel&amp;ditel</author>
                        <ISBN>123-456-781</ISBN>
                        <publisher>person</publisher>
                        <edition>3</edition>
                        <price>450</price>
            </book>
</bookstore>


Ex : 7B                         CREATION OF SCHEMA FOR BOOK STORE
.XML FILE
<?xml version="1.0"?>
<x:books xmlns:x="urn:books"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:books books.xsd">
<book id="bk001">
<author>Hightower, Kim</author>
<title>The First Book</title>
<genre>Fiction</genre>
<price>44.95</price>
<review>An amazing story of nothing.</review>
</book>
<book id="bk003">
<author>Nagata, Suanne</author>
<title>Becoming Somebody</title>
<genre>Biography</genre>
<price>24.95</price>
<review>A masterpiece of the fine art of gossiping.</review>
</book>
<book id="bk002">
<author>Oberg, Bruce</author>
<title>The Poet's First Poem</title>
<genre>Poem</genre>
<price>24.95</price>
<review>The least poetic poems of the decade.</review>
</book>
</x:books>

.XSD FILE
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:books"
xmlns:bks="urn:books">
<xsd:element name="books" type="bks:BooksForm"/>
<xsd:complexType name="BooksForm">
<xsd:sequence>
<xsd:element name="book"
type="bks:BookForm"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BookForm">
<xsd:sequence>
<xsd:element name="author"   type="xsd:string"/>
<xsd:element name="title"    type="xsd:string"/>
<xsd:element name="genre"    type="xsd:string"/>
<xsd:element name="price"    type="xsd:float" />
<xsd:element name="review"   type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id"   type="xsd:string"/>
</xsd:complexType>
</xsd:schema>

No comments:

Post a Comment