| | |
images and text applying fading-scroller effect
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hello...
i want to do "images and text" which is in database...that content fetch in user's side....but sliding problem occuring...for example i have 5 images and 5 descriptions is der..so i want to show image[1],description[1] after some milliseconds image[2],description[2] .....etc
like this...but all images are displaying once..that is my problem.. anybody plz look at this............below given my problem...in that which code i put in comments that is working but when i am retriving from database that s nt working.....
<code>
<html>
<head>
<script language="JavaScript1.2">
function reapply(){
setTimeout("slideit()",7000)
return true
}
window.onerror=reapply
</script>
<script language="JavaScript1.1">
<!--
<? $select=mysql_query("select * from successstory where status=1");
$num=mysql_num_rows($select);
$i=0;
while($fetch=mysql_fetch_array($select)){
if($i<$num)
{
?>
var image[]=new Image()
alert('<? echo $i; ?>' );
image.src="successphotos/<? echo $fetch['photo'];?>"
/*var image1=new Image()
image1.src="userphotos/x.jpg"
var image2=new Image()
image2.src="userphotos/v.jpg"
var image3=new Image()
image3.src="userphotos/b.jpg"*/
//-->
<? $i++; } }?>
//-->
</script>
</head>
<body>
<div class="ss_storiesbox">
<? $select=mysql_query("select * from successstory where status=1");
$num=mysql_num_rows($select);
$i=0;
while($fetch=mysql_fetch_array($select)){
if($i<$num)
{
echo $i;
?><script type="text/javascript">
var delay = 1600; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)
var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarations
fcontent['<? echo $i; ?>']='<? echo $fetch[description] ?> '
/*fcontent[0]="<b>murali Weads ****</b><br>No doubt, Meresathi.com is a good website. Well, we seriously thinking about the marriage. We both were searching... <a href=Readmore.php>Readmore</a>....<br><br>";
fcontent[1]="<b>xxxx Weads xxxx</b><br>it was frm the 1<sup>st</sup> time i saw her profile i decided to initiate. By grace of GOD everything moved smoothly and positively ahead.. <a href=Readmore.php>Readmore</a>....<br>";
fcontent[2]="<b>yyyy Weads yyyy</b><br>arriages Are made in heaven but still you need a medium for communication between two souls.Jeevansathi.... <a href=Readmore.php>Readmore</a>....<br>";
*/closetag='</div>';
var fwidth='250px'; //set scroller width
var fheight='100px'; //set scroller height
var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.
///No need to edit below this line/////////////////
var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;
//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
if (fadelinks)
linkcolorchange(1);
colorfade(1, 15);
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
index++
}
// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
// Modified by Dynamicdrive.com
function linkcolorchange(step){
var obj=document.getElementById("fscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color=getstepcolor(step);
}
}
var fadecounter;
function colorfade(step) {
if(step<=maxsteps) {
document.getElementById("fscroller").style.color=getstepcolor(step);
if (fadelinks)
linkcolorchange(step);
step++;
fadecounter=setTimeout("colorfade("+step+")",stepdelay);
}else{
clearTimeout(fadecounter);
document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
setTimeout("changecontent()", delay);
}
}
function getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor[i]-endcolor[i]);
if(diff > 0) {
newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
} else {
newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}
if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');
if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent
</script></div>
<div class="imgbox_ss">
<a href="javascript:slidelink()" onMouseover="window.status='Click on the image to learn more about it!';return true" onMouseout="window.status=''"><img src="successphotos/<? echo $fetch['photo'];?>" name="slide" width="101" height="101" border=0 style="filter:blendTrans(duration=3)"/></a>
<script>
<!--
////change number of images below
var number_of_images='<? echo $num; ?>'
//change speed below (in seconds)
var speed=3
var step=1
var whichimage=1
function slideit(){
if (!document.images)
return
if (document.all)
slide.filters.blendTrans.apply()
document.images.slide.src=eval("image"+step+".src")
if (document.all)
slide.filters.blendTrans.play()
whichimage=step
if (step<number_of_images)
step++
else
step=1
if (document.all)
setTimeout("slideit()",speed*1000+1000)
else
setTimeout("slideit()",speed*1000)
}
function slidelink(){
if (whichimage=='<?=$num?>')
window.location="index.php"
/*else if (whichimage==2)
window.location="index.php"
else if (whichimage==3)
window.location="index.php"*/
}
//-->
</script>
<? $i++;
}
}
?>
</div>
</div>
</div>
</body>
</html>
</code>
i want to do "images and text" which is in database...that content fetch in user's side....but sliding problem occuring...for example i have 5 images and 5 descriptions is der..so i want to show image[1],description[1] after some milliseconds image[2],description[2] .....etc
like this...but all images are displaying once..that is my problem.. anybody plz look at this............below given my problem...in that which code i put in comments that is working but when i am retriving from database that s nt working.....
<code>
<html>
<head>
<script language="JavaScript1.2">
function reapply(){
setTimeout("slideit()",7000)
return true
}
window.onerror=reapply
</script>
<script language="JavaScript1.1">
<!--
<? $select=mysql_query("select * from successstory where status=1");
$num=mysql_num_rows($select);
$i=0;
while($fetch=mysql_fetch_array($select)){
if($i<$num)
{
?>
var image[]=new Image()
alert('<? echo $i; ?>' );
image.src="successphotos/<? echo $fetch['photo'];?>"
/*var image1=new Image()
image1.src="userphotos/x.jpg"
var image2=new Image()
image2.src="userphotos/v.jpg"
var image3=new Image()
image3.src="userphotos/b.jpg"*/
//-->
<? $i++; } }?>
//-->
</script>
</head>
<body>
<div class="ss_storiesbox">
<? $select=mysql_query("select * from successstory where status=1");
$num=mysql_num_rows($select);
$i=0;
while($fetch=mysql_fetch_array($select)){
if($i<$num)
{
echo $i;
?><script type="text/javascript">
var delay = 1600; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)
var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarations
fcontent['<? echo $i; ?>']='<? echo $fetch[description] ?> '
/*fcontent[0]="<b>murali Weads ****</b><br>No doubt, Meresathi.com is a good website. Well, we seriously thinking about the marriage. We both were searching... <a href=Readmore.php>Readmore</a>....<br><br>";
fcontent[1]="<b>xxxx Weads xxxx</b><br>it was frm the 1<sup>st</sup> time i saw her profile i decided to initiate. By grace of GOD everything moved smoothly and positively ahead.. <a href=Readmore.php>Readmore</a>....<br>";
fcontent[2]="<b>yyyy Weads yyyy</b><br>arriages Are made in heaven but still you need a medium for communication between two souls.Jeevansathi.... <a href=Readmore.php>Readmore</a>....<br>";
*/closetag='</div>';
var fwidth='250px'; //set scroller width
var fheight='100px'; //set scroller height
var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.
///No need to edit below this line/////////////////
var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;
//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
if (fadelinks)
linkcolorchange(1);
colorfade(1, 15);
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
index++
}
// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
// Modified by Dynamicdrive.com
function linkcolorchange(step){
var obj=document.getElementById("fscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color=getstepcolor(step);
}
}
var fadecounter;
function colorfade(step) {
if(step<=maxsteps) {
document.getElementById("fscroller").style.color=getstepcolor(step);
if (fadelinks)
linkcolorchange(step);
step++;
fadecounter=setTimeout("colorfade("+step+")",stepdelay);
}else{
clearTimeout(fadecounter);
document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
setTimeout("changecontent()", delay);
}
}
function getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor[i]-endcolor[i]);
if(diff > 0) {
newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
} else {
newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}
if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>');
if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent
</script></div>
<div class="imgbox_ss">
<a href="javascript:slidelink()" onMouseover="window.status='Click on the image to learn more about it!';return true" onMouseout="window.status=''"><img src="successphotos/<? echo $fetch['photo'];?>" name="slide" width="101" height="101" border=0 style="filter:blendTrans(duration=3)"/></a>
<script>
<!--
////change number of images below
var number_of_images='<? echo $num; ?>'
//change speed below (in seconds)
var speed=3
var step=1
var whichimage=1
function slideit(){
if (!document.images)
return
if (document.all)
slide.filters.blendTrans.apply()
document.images.slide.src=eval("image"+step+".src")
if (document.all)
slide.filters.blendTrans.play()
whichimage=step
if (step<number_of_images)
step++
else
step=1
if (document.all)
setTimeout("slideit()",speed*1000+1000)
else
setTimeout("slideit()",speed*1000)
}
function slidelink(){
if (whichimage=='<?=$num?>')
window.location="index.php"
/*else if (whichimage==2)
window.location="index.php"
else if (whichimage==3)
window.location="index.php"*/
}
//-->
</script>
<? $i++;
}
}
?>
</div>
</div>
</div>
</body>
</html>
</code>
Last edited by muralikalpana; Oct 9th, 2009 at 10:17 am.
![]() |
Similar Threads
- Adding text to Slideshow script for images (JavaScript / DHTML / AJAX)
- Specifying the bg & hover images of a div using the value supplied in a text box (JavaScript / DHTML / AJAX)
- Picture effect (JavaScript / DHTML / AJAX)
- iPlayer Scrolling Images and Text (JavaScript / DHTML / AJAX)
- Mixing images and text in a table cell (JavaScript / DHTML / AJAX)
- want to move the scroller up a little (HTML and CSS)
- Random text and images (JavaScript / DHTML / AJAX)
- Amazing Website Designs - How do they do this? (Site Layout and Usability)
- Help: Only last loaded javascript runs (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: How store and download audio file in database?
- Next Thread: display image sequentially in PHP and MySQL
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube





