Ajax Slider
<?php
$youtextFromDb=`Windows Azure™ is a cloud services operating system that
serves as the development, service hosting and service management environment
for the Windows Azure platform.`;
$x=1;
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajax Example</title>
<script language="javascript" type="text/javascript">
function getXmlHttpReq(){var req;if(window.XMLHttpRequest && !(window.ActiveXObject)){try {req = new XMLHttpRequest();}
catch(e) {req = false;}// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {try {req = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {try {
req = new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {req = false;}}}return req;}
var prevtext="";
function viewall(id){
var spliter=id.split(`Article`);
var Articleid=spliter[1];
var req=getXmlHttpReq();
prevtext=document.getElementById(id).innerHTML;
var url="indexAction.php?Articleid="+Articleid;
req.open("GET", url, true);
req.setRequestHeader(`Content-Type`, `application/x-www-form-urlencoded`);
req.onreadystatechange = function()
{
if (req.readyState == 4 )
{
eResp=req.responseText;
var makeHidelink="[ <a href="javascript:void(0)" onclick="hide(`"+Articleid+"`)">hide</a> ]";
document.getElementById(id).innerHTML=eResp;
document.getElementById(`hide`+Articleid).innerHTML=makeHidelink
}
};
req.send(null);
}
function hide(id){
var xx=`Article`+id;
document.getElementById(xx).innerHTML=prevtext;
var makeHidelink="[ <a href="javascript:void(0)" onclick="viewall(`"+xx+"`)">more</a> ]";
document.getElementById(`hide`+id).innerHTML=makeHidelink
}
</script>
</head>
<body>
<? for($x=1;$x<=3;$x++){?>
<div id="Article<?=$x?>" style="width:300px; text-align:justify; font-family:Verdana, Geneva, sans-serif; font-size:12px" align="center">
<?=$youtextFromDb?></div>
<div id="hide<?=$x?>" style="padding-left:250px">[ <a href="javascript:void(0)" onclick="viewall(`Article<?=$x?>`)">more</a> ]</div>
<br/>
<? }?>
</body>
</html>
The indexAction is:
<?php
$Articleid=$_REQUEST[`Articleid`];
/////
// Do all the databasle operation using this id and featch all data for this id.
// Let say i get a data from databse like as following..
////
$strfromDb=`Windows Azure™ is a cloud services operating system that serves as the development, service hosting and service management environment for the Windows Azure platform. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage web applications on the internet through Microsoft® datacenters.
Windows Azure is a flexible platform that supports multiple languages and integrates with your existing on-premises environment. To build applications and services on Windows Azure, developers can use their existing Microsoft Visual Studio® expertise. In addition, Windows Azure supports popular standards and protocols including SOAP, REST, XML, and PHP. `;
echo $strfromDb;
?>
Click here to download this file