Jump to content

Have script that I would like to run continuously.


flexxall

Recommended Posts

heres the code i wish to repeat without the whole page reloading

<style type="text/css"> 
.containerdiv { float: left; position: relative; } 
.cornerimage0 { position: absolute; top: 325px; left: 114px; }
</style>
<div class="containerdiv">
    <img src="{T_IMAGESET_PATH}/site.jpg" width="900" height="380"/>
    <a href=page1.php><img class="cornerimage0" src="./images/random0.php"/>
</dev>

 

Thats really what I know. If either of the above would work please advise. I hope that helps clear things up as to what im trying to do.

Link to comment
Share on other sites

You'll need to use AJAX.

lol, why? php is more than capable.

 

 

<?php
$loop = 'true';
while ($loop == 'true') {

echo '<style type="text/css">
.containerdiv { float: left; position: relative; }
.cornerimage0 { position: absolute; top: 325px; left: 114px; }
</style>
<div class="containerdiv">
    <img src="{T_IMAGESET_PATH}/site.jpg" width="900" height="380"/>
    <a href=page1.php><img class="cornerimage0" src="./images/random0.php"/>
</dev>';

}

?>

Link to comment
Share on other sites

ok so now if I added in the fact that on the images that are randomly being displayed when they are clicked and it loads the user to a new page can the image that was clicked be removed and replaced by another random image ? or have i lost you now ?

Link to comment
Share on other sites

Moving to JavaScript section,

Its not really an AJAX issue as the server doesn't need to poll a query.. just refresh the image

 

I assume its just this line that needs to be refresh

<img class="cornerimage0" src="./images/random0.php"/>

 

update to

<img id="dymImg" class="cornerimage0" src="./images/random0.php"/>

 

and add this script

 

<script> 
var dymImg; 
var imgBase="./images/random0.php?" 
var c = 0; 
function count() 
{ 
	dymImg.src=imgBase+(++c); 
} 
function init() 
{ 
	dymImg= document.getElementById("dymImg"); 
	if( dymImg) 
	{ 
		setInterval("count()",1000); 
	} 
} 
window.onload = init; 
</script> 

Link to comment
Share on other sites

try this

 

(only a slight change)

<img id="dymImg" class="cornerimage0" src="./images/random0.php?"/>

<script>
var dymImg;
var imgBase="./images/random0.php?" 
var c = 0;
function count()
{
	c++;
	dymImg.src=imgBase+c;
}
function init()
{
	dymImg= document.getElementById("dymImg");
	if( dymImg)
	{
		setInterval("count()",1000);
	}
}
window.onload = init;
</script> 

Link to comment
Share on other sites

I know you could write this a better way but

this should work

<img id="dymImg0" class="cornerimage0" src="./images/random0.php"/>
<img id="dymImg1" class="cornerimage1" src="./images/random1.php"/>
<!-- ADD -->
<script>
var dymImg= new Array();
var imgBase= new Array();
imgBase[0] = "./images/random0.php?";
imgBase[1] = "./images/random1.php?";
//ADD

var c = 0;
function count()
{
	c++;
	T=imgBase.length;
	for(n=0;n<t;n++)
	{
		dymImg[n].src=imgBase[n]+c;
	}
}
function init()
{
	dymImg[0]= document.getElementById("dymImg0");
	dymImg[1]= document.getElementById("dymImg1");
	//ADD
	setInterval("count()",1000);
}
window.onload = init;
</script> 

 

if it works then add the rest to the 3 add points

Link to comment
Share on other sites

Moving to JavaScript section,

Its not really an AJAX issue as the server doesn't need to poll a query.. just refresh the image

 

I assume its just this line that needs to be refresh

<img class="cornerimage0" src="./images/random0.php"/>

 

update to

<img id="dymImg" class="cornerimage0" src="./images/random0.php"/>

 

It was actually based off of this code that the repeat worked. I tried the second code but it places the image in the wrong location.

 

 

and add this script

 

<script> 
var dymImg; 
var imgBase="./images/random0.php?" 
var c = 0; 
function count() 
{ 
	dymImg.src=imgBase+(++c); 
} 
function init() 
{ 
	dymImg= document.getElementById("dymImg"); 
	if( dymImg) 
	{ 
		setInterval("count()",1000); 
	} 
} 
window.onload = init; 
</script> 

Link to comment
Share on other sites

If you image is in the wrong place then check the class

 

as the first class was called cornerimage0 i assumed the next one would be cornerimage1

so i did

<img id="dymImg0" class="cornerimage0" src="./images/random0.php"/>
<img id="dymImg1" class="cornerimage1" src="./images/random1.php"/>

in my last example

Link to comment
Share on other sites

It seems when I use this code

<script>
   var dymImg= new Array();
   var imgBase= new Array();
   imgBase[0] = "./images/random0.php?";
   imgBase[1] = "./images/random1.php?";
   //ADD
   
   var c = 0;
   function count()
   {
      c++;
      T=imgBase.length;
      for(n=0;n<t;n++)
      {
         dymImg[n].src=imgBase[n]+c;
      }
   }
   function init()
   {
      dymImg[0]= document.getElementById("dymImg0");
      dymImg[1]= document.getElementById("dymImg1");
      //ADD
      setInterval("count()",1000);
   }
   window.onload = init;
</script> 

<style type="text/css"> 
.containerdiv { float: left; position: relative; } 
.cornerimage0 { position: absolute; top: 325px; left: 114px; }
.cornerimage1 { position: absolute; top: 314px; left: 231px; }
.cornerimage2 { position: absolute; top: 310px; left: 468px; }
.cornerimage3 { position: absolute; top: 334px; left: 700px; }
.cornerimage4 { position: absolute; top: 200px; left: 150px; }
.cornerimage5 { position: absolute; top: 200px; left: 650px; }
.cornerimage6 { position: absolute; top: 250px; left: 212px; }
.cornerimage7 { position: absolute; top: 275px; left: 750px; }
.cornerimage8 { position: absolute; top: 118px; left: 150px; }
.cornerimage9 { position: absolute; top: 118px; left: 650px; } 
</style>
<div class="containerdiv">
    <img src="{T_IMAGESET_PATH}/site.jpg" width="900" height="380"/>
    <a href=page0.php><img id="dymImg0" class="cornerimage0" src="./images/random0.php"/>
    <a href=page1.php><img id="dymImg1" class="cornerimage1" src="./images/random1.php"/>

</div>

 

 

This is not working. I noticed that you placed the img tag above the script. does that have anything to do with it ? and in the first script it seems the img was not added.

 

Like this works but for just one of the images

<script>
   var dymImg;
   var imgBase="./images/random0.php?"
   var c = 0;
   function count()
   {
      dymImg.src=imgBase+(++c);
   }
   function init()
   {
      dymImg= document.getElementById("dymImg");
      if( dymImg)
      {
         setInterval("count()",1000);
      }
   }
   window.onload = init;
</script> 

<style type="text/css"> 
.containerdiv { float: left; position: relative; } 
.cornerimage0 { position: absolute; top: 325px; left: 114px; }
.cornerimage1 { position: absolute; top: 314px; left: 231px; }
.cornerimage2 { position: absolute; top: 310px; left: 468px; }
.cornerimage3 { position: absolute; top: 334px; left: 700px; }
.cornerimage4 { position: absolute; top: 200px; left: 150px; }
.cornerimage5 { position: absolute; top: 200px; left: 650px; }
.cornerimage6 { position: absolute; top: 250px; left: 212px; }
.cornerimage7 { position: absolute; top: 275px; left: 750px; }
.cornerimage8 { position: absolute; top: 118px; left: 150px; }
.cornerimage9 { position: absolute; top: 118px; left: 650px; } 
</style>
<div class="containerdiv">
    <img src="{T_IMAGESET_PATH}/site_adopt.jpg" width="900" height="380"/>
    <a href=page0.php><img id="dymImg" class="cornerimage0" src="./images/random0.php"/>
<a href=page1.php><img id="dymImg" class="cornerimage1" src="./images/random1.php"/>

</div>

Link to comment
Share on other sites

Yes, your probably want to double up on the images and have some preloads to make it smooth

 

However that's for another thread

if you create a new thread (link to this thread if needed)

 

I going to get some sleep but if (I remember) I'll check for your new post in the morning

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.