27.
Write
an Ajax program to display list of games stored in an array on clicking OK button.
Html file :
<html>
<head>
<script
>
function dis()
{var ob=false;
ob=new XMLHttpRequest();
var
gm=document.getElementById("gm").value;
ob.open("GET","slip27.php?game="+gm);
ob.send();
ob.onreadystatechange=function()
{ if(ob.readyState==4
&& ob.status==200)
{
document.getElementById("game").innerHTML=ob.responseText;
}
}
Php file
:
}
</script>
</head>
<body>
<h2>Display
the list of Games<input type=button name=submit value=OK
id="gm" onClick="dis()"></h2>
<span
id="game"></span>
</body>
</html>
Php file
:
<?php
$gm=$_GET['game'];
$a=array("Hockey","Football","Cricket","Basket
Ball","Kho-Kho","Tennis","Dough Ball");
echo "<h3>List of Games<br></h3>";
for($i=0;$i<count($a);$i++)
{
echo $a[$i]."<br>";
}
?>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.