SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

&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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 
Java.script
Java.scriptJava.script
Java.script
 
Html
HtmlHtml
Html
 
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
 

Kürzlich hochgeladen

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 

Kürzlich hochgeladen (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

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