Click to See Complete Forum and Search --> : Need help with scrolling box


jimbobbowles
02-17-2004, 02:03 PM
I'm a novice at javascript and am trying to get this scrolling calendar to work. Could anyone help me with it? It keeps resetting about 75% of the way through, but I can't make it scroll through the whole thing. Its at http://www.aaaawest.com/TSF/teasavoirfaire.html.

Thanks for any help!

jimbobbowles
02-17-2004, 02:21 PM
Script looks like this in the head:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
//slider's width
var swidth=350

//slider's height
var sheight=250

//slider's speed
var sspeed=2

var singletext=new Array()
singletext[0]='<p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Tea Room 101: The Art of Owning a Tea Room, with James Norwood Pratt, March 19-21, Perryville, Kentucky. Contact: Elmwood Inn at </font></span><font size="2" face="Verdana"><a target="_blank" href="http://www.elmwoodinn.com/">www.elmwoodinn.com</a></font></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Train to Be a Corporate Etiquette and International Protocol Consultant ®, March 27-32, May 1-5, August 21-25, and October 23-27, Portland, Maine. Contact: The Protocol School of Washington® at </font></span><a target="_blank" href="http://www.psow.com/"><font size="2" face="Verdana">www.psow.com</font></a></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Take Me 2Tea Expo, March 28-30, Las Vegas. Contact: Take me 2Tea at </font></span><font face="Verdana"><font size="2">&nbsp;</font><a target="_blank" href="http://www.takeme2tea.com/"><font size="2">www.takeme2tea.com</font></a></font></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Operating a Tea Business for Profit and Pleasure, May 14-17, July 16-19, September 8-11, and October 15-18, Vancouver, Washington. Contact: Carnelian Rose Tea Company at </font></span><font size="2" face="Verdana"><a target="_blank" href="http://www.carnelianrosetea.com/">www.carnelianrosetea.com</a>.</font></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Tea Room 101: The Art of Owning a Tea Room at Lady Primrose’s Thatched Cottage Tea Room, May 16-18, Dallas. Contact: Elmwood Inn, </font></span><a target="_blank" href="http://www.elmwoodinn.com/"><font size="2" face="Verdana">www.elmwoodinn.com</font></a></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">English Tea and Garden Tour, featuring London and Southeast England, May 19-29.&nbsp; Contact: TheTeaTime Tours, </font></span><a target="_blank" href="http://www.teatimegazette.com/"><font size="2" face="Verdana">www.teatimegazette.com</font></a></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Train to be a Children’s Etiquette Consultant®, June 5-8 and September 25-28, Portland, Maine. Contact: The Protocol School of Washington® at </font></span><a target="_blank" href="http://www.psow.com/"><font size="2" face="Verdana">www.psow.com</font></a></p><p class="MsoNormal"><span style="font-family: Verdana"><font size="2">Tea Room 101: The Art of Owning a Tea Room, September 24-26, The Grand Floridian Resort and Spa at Walt Disney World, Orlando. Contact: Elmwood Inn at </font></span><a target="_blank" href="http://www.elmwoodinn.com/"><font size="2" face="Verdana">www.elmwoodinn.com</font></a>.'

if (singletext.length>1)
i=1
else
i=0
function start(){
if (document.all){
ieslider1.style.top=sheight
iemarquee(ieslider1)
}
else if (document.layers){
document.ns4slider.document.ns4slider1.top=sheight
document.ns4slider.document.ns4slider1.visibility='show'
ns4marquee(document.ns4slider.document.ns4slider1)
}
else if (document.getElementById&&!document.all){
document.getElementById('ns6slider1').style.top=sheight
ns6marquee(document.getElementById('ns6slider1'))
}
}

function iemarquee(whichdiv){
iediv=eval(whichdiv)
if (iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){
iediv.style.pixelTop=0
setTimeout("iemarquee(iediv)",100)
}
if (iediv.style.pixelTop>=sheight*-1){
iediv.style.pixelTop-=sspeed
setTimeout("iemarquee(iediv)",100)
}
else{
iediv.style.pixelTop=sheight
iediv.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}

function ns4marquee(whichlayer){
ns4layer=eval(whichlayer)
if (ns4layer.top>0&&ns4layer.top<=sspeed){
ns4layer.top=0
setTimeout("ns4marquee(ns4layer)",100)
}
if (ns4layer.top>=sheight*-1){
ns4layer.top-=sspeed
setTimeout("ns4marquee(ns4layer)",100)
}
else{
ns4layer.top=sheight
ns4layer.document.write(singletext[i])
ns4layer.document.close()
if (i==singletext.length-1)
i=0
else
i++
}
}

function ns6marquee(whichdiv){
ns6div=eval(whichdiv)
if (parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){
ns6div.style.top=0
setTimeout("ns6marquee(ns6div)",100)
}
if (parseInt(ns6div.style.top)>=sheight*-1){
ns6div.style.top=parseInt(ns6div.style.top)-sspeed
setTimeout("ns6marquee(ns6div)",100)
}
else{
ns6div.style.top=sheight
ns6div.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}
// End -->
</script>

jimbobbowles
02-17-2004, 11:01 PM
bump



Still needing some help with this. Thanks!

Pittimann
02-18-2004, 06:56 AM
Hi!

Due to the fact, that your site won't work in NS4.x I just dealt with Mozilla and IE.

You simply have to alter two functions. I put them here completely, so you just replace the old ones with the new ones and the stuff should work (alternativly only replace the lines commented as modified):

function iemarquee(whichdiv){
iediv=eval(whichdiv)
if (iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){
iediv.style.pixelTop=0
setTimeout("iemarquee(iediv)",15)
}
if (iediv.style.pixelTop>=iediv.offsetHeight*-1){//modified!
iediv.style.pixelTop-=sspeed
setTimeout("iemarquee(iediv)",15)
}
else{
iediv.style.pixelTop=sheight
iediv.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}
//I left this one out
function ns4marquee(whichlayer){
}
//end of "left out"
function ns6marquee(whichdiv){
ns6div=eval(whichdiv)
if (parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){
ns6div.style.top=0
setTimeout("ns6marquee(ns6div)",15)
}
if (parseInt(ns6div.style.top)>=ns6div.offsetHeight*-1){//modified!
ns6div.style.top=parseInt(ns6div.style.top)-sspeed
setTimeout("ns6marquee(ns6div)",15)
}
else{
ns6div.style.top=sheight
ns6div.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}

Cheers - Pit

kittytaht
02-18-2004, 07:33 AM
couldn't you just use a scrolling div using css?

#somediv {height: 100px;width: 300px;overflow: auto;}

jimbobbowles
02-18-2004, 08:42 AM
Thanks for your help. Had to tweak a couple things to make it slow down.






Don't know about the css, but I borrowed the code anyway. Just couldn't get it to work 100% correctly.

Pittimann
02-18-2004, 08:46 AM
Hi!

Sorry - I accelerated the speed for a little test and forgot to increase it again :(...

Cheers - Pit