SlideShare a Scribd company logo
T.Y. BSc Computer Science
Practical No:- 10
Practical Name: Create a webpage using Ajax, having a text Box for accepting a number
check whether the number is even or odd using php and dispay the output.
Date: 04/02/2016
Source Code:
Evenno.php
<?php
$q=$_REQUEST["q"]; $hint="";
if ($q !== "")
{
if ($q%2==0)
echo "Even Number";
else
echo "odd Number";
}
else
echo $hint==="" ? "no suggestion" : $hint;
?>
Evenno.html
<html>
<head>
<script>
functionshowHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
varxmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 &&xmlhttp.status==200)
{
T.Y. BSc Computer Science
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","Evenno.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
Enter Number: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Suggestions: <span id="txtHint"></span></p>
</body>
</html>
Output:
T.Y. BSc Computer Science
T.Y. BSc Computer Science
Practical No:- 11
Practical Name: Write a program to find the factorial of the given number.
Date: 11/02/2016
Source Code:
Factno.php
<?php
$q=$_REQUEST["q"];
$hint="";
$fact=1;
if($q!=="")
{
while($q>0)
{
$fact=$fact*$q;
$q--;
}
echo "$fact";
}
else
echo $hint==="" ? "no suggestion" : $hint;
?>
Factno.html
<html>
<head>
<script>
functionshowHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
varxmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 &&xmlhttp.status==200)
T.Y. BSc Computer Science
{
document.getElementById
("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","factorial.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
Enter Number: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Suggestions: <span id="txtHint"></span></p>
</body>
</html>
Output:
T.Y. BSc Computer Science
Practical No:- 12
Practical Name: create a webpage using Ajax having a textbox for accepting a number
calculate thereverse of this number using PHP& display the output.
Date: 18/02/2016
Source Code:
Reverse.php
<?php
$q=$_REQUEST["q"];
$hint="";
$fact=1;
if($q !=="")
{
while($q>0)
{
$temp=$q%10;
echo "$temp";
if($temp==0)
break;
$q=$q/10;
}
}
else
echo $hint==="" ? "no suggestion" : $hint;
?>
ReverseNumber.html
<html>
<head>
<script>
functionshowHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
varxmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
T.Y. BSc Computer Science
{
if (xmlhttp.readyState==4 &&xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","reverse.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
Enter Number: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Suggestions: <span id="txtHint"></span></p>
</body>
</html>
Output:
T.Y. BSc Computer Science
Practical No:- 13
Practical Name: Create an html file to fetch the contents ofDanceAcademy.xml using Ajax
&display them in a table.
Date: 25/02/2016
Source Code:
DANCE ACADEMY:
<?xml version="1.0" encoding="windows-1252"?>
<!-- Edited by XMLSpy® -->
<DANCE ACADEMY>
<DANCECOURSES>
<DANCESTYLE>hip hop</DANCESTYLE>
<DANCEFEES>1000</DANCEFEES>
</DANCECOURSES>
<DANCECOURSES>
<DANCESTYLE>break dance </DANCESTYLE>
<DANCEFEES>2000</DANCEFEES>
</DANCECOURSES>
<DANCECOURSES>
<DANCESTYLE>b boying </DANCESTYLE>
<DANCEFEES>1500</DANCEFEES>
</DANCECOURSES>
<DANCECOURSES>
<DANCESTYLE>tollywood </DANCESTYLE>
<DANCEFEES>3000</DANCEFEES>
</DANCECOURSES>
<DANCECOURSES>
<DANCESTYLE>bollywood</DANCESTYLE>
<DANCEFEES>4500</DANCEFEES>
</ DANCECOURSES>
</DANCE ACADEM >
T.Y. BSc Computer Science
DANCEINFO:
<!DOCTYPE html>
<html>
<head>
<script>
functionloadXMLDoc(url)
{
varxmlhttp;
vartxt,x,xx,i;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 &&xmlhttp.status==200)
{
txt="<table border='1'><tr><th>Title</th><th>Price</th></tr>";
x=xmlhttp.responseXML.documentElement.getElementsByTagName("DANCECOURSES")
;
for (i=0;i<x.length;i++)
{
txt=txt + "<tr>";
xx=x[i].getElementsByTagName("DANCESTYLE");
{
try
{
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er)
{
txt=txt + "<td></td>";
}
}
xx=x[i].getElementsByTagName("DANCEFEES");
{
try
{
T.Y. BSc Computer Science
txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er)
{
txt=txt + "<td></td>";
}
}
txt=txt + "</tr>";
}
txt=txt + "</table>";
document.getElementById('txtCDInfo').innerHTML=txt;
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="txtCDInfo">
<button onclick="loadXMLDoc('info.xml')">Display Dance list</button>
</div>
</body>
</html>
Output:
Practical No:- 14
T.Y. BSc Computer Science
Practical Name: Create login form username and password that validates input data in PHP
file and display appropriate message.
Date: 03/03/2016
Source Code:
usernamedemo1.html
<html>
<head>
<script>
function showHint(str)
{
if (str.length==0)
{
document.getElementById
("txtHint").innerHTML="";
return;
}
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4
&&xmlhttp.status==200)
{
document.getElementById
("txtHint").innerHTML=xmlhttp.responseText;
}
T.Y. BSc Computer Science
}
xmlhttp.open("GET","username1.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
Enter Username: <input type="text"><br>
Enter Password: <input type="text"
onkeyup="showHint(this.value)">
</form>
<p><span id="txtHint"></span></p>
</body>
</html>
username1.php
<?php
$q=$_REQUEST["q"]; $hint="";
// lookup all hints from array if $q is different from ""
if ($q == "123")
{
echo "password is correct....";
}
T.Y. BSc Computer Science
else
echo "password is incorrect"
?>
Output:
Practical No:- 15
T.Y. BSc Computer Science
Practical Name: Retrieving student details from the database using ajax and php file.
Date: 10/03/2016
Source Code:
Insert. html
<html>
<body>
Marks data:
<br>
<form action="insert.php" method="post">
First Name: <input type="text" name="fname"><br>
Last Name: <input type="text" name="lname"><br>
Marks: <input type="text" name="marks"><br>
<input type="submit" name="submit">
</form>
</body>
</html>
Insert.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student";
$fnm = $_POST['fname'];
$lnm = $_POST['lname'];
$marks = $_POST['marks'];
T.Y. BSc Computer Science
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO marks (fname, lname, mark)
VALUES ('$fnm', '$lnm', '$marks')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Output:
T.Y. BSc Computer Science
Practical No:- 16
Practical Name: Using of Absolute and Relative
T.Y. BSc Computer Science
Date: 10/03/2016
Source Code:
Absolute.html
<html>
<head>
<title>
Absolute Positioning
</title>
</head>
<body>
<h1 align="center">
Absolute Positioning
</h1>
<div style="position:absolute; left:50; top:60;">
<img src="image1.jpg" width=205 height=120>
<br>
Image 1
</div>
<div style="position:absolute; left:200; top:90;">
<img src="image2.jpg" width=205 height=120>
<br>
Image 2
</div>
<div style="position:absolute; left:350; top:120;">
<img src="image3.jpg" width=205 height=120>
<br>
Image 3
</div>
</body>
</html>
Relative.Html
<html>
<head>
T.Y. BSc Computer Science
<title>
Relative Positioning
</title>
</head>
<body>
<h1 align="center">
Relative Positioning
</h1>
Do you like
<span style="position: relative; top: -5">roller</span>
<span style="position: relative; top: 5">coasters</span> as much as I
do?
</body>
</html>
Output:
T.Y. BSc Computer Science

More Related Content

What's hot

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 
Declarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspectiveDeclarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspective
Maxim Avanov
 
Html basics 11 form validation
Html basics 11 form validationHtml basics 11 form validation
Html basics 11 form validation
H K
 

What's hot (20)

Ans
AnsAns
Ans
 
PHP - Introduction to PHP Forms
PHP - Introduction to PHP FormsPHP - Introduction to PHP Forms
PHP - Introduction to PHP Forms
 
Javascript
JavascriptJavascript
Javascript
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Declarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspectiveDeclarative Programming & Algebraic Data Types from Django's perspective
Declarative Programming & Algebraic Data Types from Django's perspective
 
PHP Form Validation Technique
PHP Form Validation TechniquePHP Form Validation Technique
PHP Form Validation Technique
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Learn php with PSK
Learn php with PSKLearn php with PSK
Learn php with PSK
 
The Ring programming language version 1.2 book - Part 31 of 84
The Ring programming language version 1.2 book - Part 31 of 84The Ring programming language version 1.2 book - Part 31 of 84
The Ring programming language version 1.2 book - Part 31 of 84
 
C5 Javascript
C5 JavascriptC5 Javascript
C5 Javascript
 
The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88
 
Data Binding: Is It the Next Big Thing?
Data Binding: Is It the Next Big Thing?Data Binding: Is It the Next Big Thing?
Data Binding: Is It the Next Big Thing?
 
Html basics 11 form validation
Html basics 11 form validationHtml basics 11 form validation
Html basics 11 form validation
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
 
Making web forms using php
Making web forms using phpMaking web forms using php
Making web forms using php
 
Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)
 
my test
my testmy test
my test
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
 

Viewers also liked

tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
WE-IT TUTORIALS
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
Salim M
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
simran153
 

Viewers also liked (18)

TYCS Training Program
TYCS Training ProgramTYCS Training Program
TYCS Training Program
 
AJAX
AJAXAJAX
AJAX
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
TYBSc[IT]_SEM-6
TYBSc[IT]_SEM-6TYBSc[IT]_SEM-6
TYBSc[IT]_SEM-6
 
Ajax chap 5
Ajax chap 5Ajax chap 5
Ajax chap 5
 
Ajax chap 2.-part 1
Ajax chap 2.-part 1Ajax chap 2.-part 1
Ajax chap 2.-part 1
 
Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
XML DOM
XML DOMXML DOM
XML DOM
 
Practical file on web technology(html)
Practical file on web technology(html)Practical file on web technology(html)
Practical file on web technology(html)
 
Data communications ch 1
Data communications   ch 1Data communications   ch 1
Data communications ch 1
 
TYBCom Computer Systems and Applications - Sem 6 - University of Mumbai
TYBCom Computer Systems and Applications - Sem 6 - University of MumbaiTYBCom Computer Systems and Applications - Sem 6 - University of Mumbai
TYBCom Computer Systems and Applications - Sem 6 - University of Mumbai
 
Python reading and writing files
Python reading and writing filesPython reading and writing files
Python reading and writing files
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax & ASP.NET 2
Ajax & ASP.NET 2Ajax & ASP.NET 2
Ajax & ASP.NET 2
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 

Similar to TYCS Ajax practicals sem VI

Doctype htm1
Doctype htm1Doctype htm1
Doctype htm1
Eddy_TKJ
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
Hitesh Patel
 
Java.script
Java.scriptJava.script
Java.script
g Nama
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
Mouli Chandira
 

Similar to TYCS Ajax practicals sem VI (20)

JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
WEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaWEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bca
 
YASH HTML CODES
YASH HTML CODESYASH HTML CODES
YASH HTML CODES
 
YASH HTML CODE
YASH HTML CODE YASH HTML CODE
YASH HTML CODE
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)
 
Doctype htm1
Doctype htm1Doctype htm1
Doctype htm1
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Ajax chap 4
Ajax chap 4Ajax chap 4
Ajax chap 4
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactor
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
 
Update statement in PHP
Update statement in PHPUpdate statement in PHP
Update statement in PHP
 
Html
HtmlHtml
Html
 
Java.script
Java.scriptJava.script
Java.script
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 

Recently uploaded

Recently uploaded (20)

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

TYCS Ajax practicals sem VI

  • 1. T.Y. BSc Computer Science Practical No:- 10 Practical Name: Create a webpage using Ajax, having a text Box for accepting a number check whether the number is even or odd using php and dispay the output. Date: 04/02/2016 Source Code: Evenno.php <?php $q=$_REQUEST["q"]; $hint=""; if ($q !== "") { if ($q%2==0) echo "Even Number"; else echo "odd Number"; } else echo $hint==="" ? "no suggestion" : $hint; ?> Evenno.html <html> <head> <script> functionshowHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } varxmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) {
  • 2. T.Y. BSc Computer Science document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","Evenno.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> Enter Number: <input type="text" onkeyup="showHint(this.value)"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> Output:
  • 4. T.Y. BSc Computer Science Practical No:- 11 Practical Name: Write a program to find the factorial of the given number. Date: 11/02/2016 Source Code: Factno.php <?php $q=$_REQUEST["q"]; $hint=""; $fact=1; if($q!=="") { while($q>0) { $fact=$fact*$q; $q--; } echo "$fact"; } else echo $hint==="" ? "no suggestion" : $hint; ?> Factno.html <html> <head> <script> functionshowHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } varxmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &&xmlhttp.status==200)
  • 5. T.Y. BSc Computer Science { document.getElementById ("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","factorial.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> Enter Number: <input type="text" onkeyup="showHint(this.value)"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> Output:
  • 6. T.Y. BSc Computer Science Practical No:- 12 Practical Name: create a webpage using Ajax having a textbox for accepting a number calculate thereverse of this number using PHP& display the output. Date: 18/02/2016 Source Code: Reverse.php <?php $q=$_REQUEST["q"]; $hint=""; $fact=1; if($q !=="") { while($q>0) { $temp=$q%10; echo "$temp"; if($temp==0) break; $q=$q/10; } } else echo $hint==="" ? "no suggestion" : $hint; ?> ReverseNumber.html <html> <head> <script> functionshowHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } varxmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function()
  • 7. T.Y. BSc Computer Science { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","reverse.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> Enter Number: <input type="text" onkeyup="showHint(this.value)"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> Output:
  • 8. T.Y. BSc Computer Science Practical No:- 13 Practical Name: Create an html file to fetch the contents ofDanceAcademy.xml using Ajax &display them in a table. Date: 25/02/2016 Source Code: DANCE ACADEMY: <?xml version="1.0" encoding="windows-1252"?> <!-- Edited by XMLSpy® --> <DANCE ACADEMY> <DANCECOURSES> <DANCESTYLE>hip hop</DANCESTYLE> <DANCEFEES>1000</DANCEFEES> </DANCECOURSES> <DANCECOURSES> <DANCESTYLE>break dance </DANCESTYLE> <DANCEFEES>2000</DANCEFEES> </DANCECOURSES> <DANCECOURSES> <DANCESTYLE>b boying </DANCESTYLE> <DANCEFEES>1500</DANCEFEES> </DANCECOURSES> <DANCECOURSES> <DANCESTYLE>tollywood </DANCESTYLE> <DANCEFEES>3000</DANCEFEES> </DANCECOURSES> <DANCECOURSES> <DANCESTYLE>bollywood</DANCESTYLE> <DANCEFEES>4500</DANCEFEES> </ DANCECOURSES> </DANCE ACADEM >
  • 9. T.Y. BSc Computer Science DANCEINFO: <!DOCTYPE html> <html> <head> <script> functionloadXMLDoc(url) { varxmlhttp; vartxt,x,xx,i; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { txt="<table border='1'><tr><th>Title</th><th>Price</th></tr>"; x=xmlhttp.responseXML.documentElement.getElementsByTagName("DANCECOURSES") ; for (i=0;i<x.length;i++) { txt=txt + "<tr>"; xx=x[i].getElementsByTagName("DANCESTYLE"); { try { txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td></td>"; } } xx=x[i].getElementsByTagName("DANCEFEES"); { try {
  • 10. T.Y. BSc Computer Science txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>"; } catch (er) { txt=txt + "<td></td>"; } } txt=txt + "</tr>"; } txt=txt + "</table>"; document.getElementById('txtCDInfo').innerHTML=txt; } } xmlhttp.open("GET",url,true); xmlhttp.send(); } </script> </head> <body> <div id="txtCDInfo"> <button onclick="loadXMLDoc('info.xml')">Display Dance list</button> </div> </body> </html> Output: Practical No:- 14
  • 11. T.Y. BSc Computer Science Practical Name: Create login form username and password that validates input data in PHP file and display appropriate message. Date: 03/03/2016 Source Code: usernamedemo1.html <html> <head> <script> function showHint(str) { if (str.length==0) { document.getElementById ("txtHint").innerHTML=""; return; } var xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &&xmlhttp.status==200) { document.getElementById ("txtHint").innerHTML=xmlhttp.responseText; }
  • 12. T.Y. BSc Computer Science } xmlhttp.open("GET","username1.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> Enter Username: <input type="text"><br> Enter Password: <input type="text" onkeyup="showHint(this.value)"> </form> <p><span id="txtHint"></span></p> </body> </html> username1.php <?php $q=$_REQUEST["q"]; $hint=""; // lookup all hints from array if $q is different from "" if ($q == "123") { echo "password is correct...."; }
  • 13. T.Y. BSc Computer Science else echo "password is incorrect" ?> Output: Practical No:- 15
  • 14. T.Y. BSc Computer Science Practical Name: Retrieving student details from the database using ajax and php file. Date: 10/03/2016 Source Code: Insert. html <html> <body> Marks data: <br> <form action="insert.php" method="post"> First Name: <input type="text" name="fname"><br> Last Name: <input type="text" name="lname"><br> Marks: <input type="text" name="marks"><br> <input type="submit" name="submit"> </form> </body> </html> Insert.php <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "student"; $fnm = $_POST['fname']; $lnm = $_POST['lname']; $marks = $_POST['marks'];
  • 15. T.Y. BSc Computer Science // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "INSERT INTO marks (fname, lname, mark) VALUES ('$fnm', '$lnm', '$marks')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> Output:
  • 16. T.Y. BSc Computer Science Practical No:- 16 Practical Name: Using of Absolute and Relative
  • 17. T.Y. BSc Computer Science Date: 10/03/2016 Source Code: Absolute.html <html> <head> <title> Absolute Positioning </title> </head> <body> <h1 align="center"> Absolute Positioning </h1> <div style="position:absolute; left:50; top:60;"> <img src="image1.jpg" width=205 height=120> <br> Image 1 </div> <div style="position:absolute; left:200; top:90;"> <img src="image2.jpg" width=205 height=120> <br> Image 2 </div> <div style="position:absolute; left:350; top:120;"> <img src="image3.jpg" width=205 height=120> <br> Image 3 </div> </body> </html> Relative.Html <html> <head>
  • 18. T.Y. BSc Computer Science <title> Relative Positioning </title> </head> <body> <h1 align="center"> Relative Positioning </h1> Do you like <span style="position: relative; top: -5">roller</span> <span style="position: relative; top: 5">coasters</span> as much as I do? </body> </html> Output:
  • 19. T.Y. BSc Computer Science