Forum Moderators: open

Message Too Old, No Replies

Need Easy Javascript Image Cookie Rotator

         

101Jen

7:27 pm on Sep 13, 2008 (gmt 0)

10+ Year Member



I need a Javascript Image Cookie Rotator that uses as little javascript as possible. I have part of it written but having trouble with the cookie part. To remember visitors last visit so it knows to show them the next array line.

This goes in body of the page
<div id="kie">
<script type="text/javascript">getkie()</script>
</div>

Connected by external .js address to this following. Want it to show these lines and real image addresses in order on a web page, on every next page load only. For some reason when I save this in webmaster there should be square brackets around array line number one number like the rest.

var kie=[];
kie[1] = ["><img style='margin-left: 10px;margin-top:10px' title='Image' border='0' src='http://www.example.com/img1.jpg' />"];
kie[2] = ["><img style='margin-left: 0px;' title='Image' border='0' src='http://www.example.com/img2.jpg' />"];
kie[3] = ["><img style='margin-left: 0px;' title='Image' border='0' src='http://www.example.com/img3.jpg' />"];
kie[4] = ["<img style='margin-left: 0px;' title='Image' border='0' src='http://www.example.com/img4.jpg' />"];

function showimg(){
document.getElementById("kie").innerHTML = }

function setkie(){}

function getkie(){}

Hope someone can help me with this, thanks a lot for your help. Jen

[edited by: 101Jen at 7:32 pm (utc) on Sep. 13, 2008]

[edited by: DrDoc at 3:34 pm (utc) on Oct. 5, 2008]

101Jen

11:58 pm on Sep 13, 2008 (gmt 0)

10+ Year Member



This goes in body of the page
<div id="kie">
<script type="text/javascript">getkie()</script>
</div>

Ok this is what I have now for the external .js:

var kie=[];
kie= ["><img style='margin-left: 10px;margin-top:10px' title='Image' border='0' src='http://www.jpg' />"];
kie[2] = ["><img style='margin-left: 0px;' title='Image' border='0' src='http://www..jpg' />"];
kie[3] = ["><img style='margin-left: 0px;' title='Image' border='0' src='http://www.jpg' />"];
kie[4] = ["<img style='margin-left: 0px;' title='Image' border='0' src='http://www.jpg' />"];

SetCookie("koo", "koo", 365);
var read = ReadCookie("koo");

function setcook2(){SetCookie("koo2", "koo2", 365);
var read2 = ReadCookie("koo2");}

var counter = 1;

function counting()
{
document.getElementById("kie").innerHTML = kie[counter];
counter++; if (counter == kie.length)
{counter = 1; }}
}

function getkie(need to tie cookies to array lines here somehow that pull it all together)

I set the first cookie named koo for the page for a year, and the script to also read the first cookie.
I also have the array counting down descending from one array line to the next.
I also have more cookies set if needed so that if page reads cookie 1 it will then go to cookie two and array line 2 and so on.

I need help tying the cookies and array lines together. So that when a visitor comes back to the page it will go to the very next array line.

Hope someone can help, thanks a lot for your help. Jen