?
Solved

Text Banners - II

Posted on 2003-03-20
3
Medium Priority
?
201 Views
Last Modified: 2010-04-06
This is a message to "neongrau", and I reopened this question in order to give it new point value:

Neongrau, you have kindly put some weeks ago this javascript below to exhibit what I called text banners. It works nicely.

But, now, supposing I need, on another location on the same page, other group of other 3 or 4 text banners, how could I implement this using the same script? I tried modifying it but I was not successful. Thanks for any help.

Mario./
_____________________________________________________________

THE ORIGINAL SCRIPT:

<script language=javascript DEFER>
function banners(count) {
 document.getElementById('layer'+banner).style.display='none';
 banner++
 if ( banner > count ) { banner=1; }
 document.getElementById('layer'+banner).style.display='block';
}
banner=6;
window.setInterval('banners(6)',1000);
</script>

<style>
.banner
{
position; absolute;
top 10px;
left: 10p;
display: none;
width: 468px;
height: 60px;
border: 1px solid black;
background: pink;
}
</style>

<body onLoad="banners(6)">

<div class=banner id="layer1">layer1</div>
<div class=banner id="layer2">layer2</div>
<div class=banner id="layer3">layer3</div>
<div class=banner id="layer4">layer4</div>
<div class=banner id="layer5">layer5</div>
<div class=banner id="layer6">layer6</div>

</body>
0
Comment
Question by:multisites
  • 2
3 Comments
 
LVL 2

Expert Comment

by:neongrau
ID: 8210597
hi!

sorry i was very stressed the last days. so i had no time to look further.

basically there's need for a completetly rewrite the function.

but a fast'n'nasty solution would be to add a second function with renamed global vars.

i'm currently looking into this and i will post it later this day.

regards
~neongrau
0
 
LVL 2

Accepted Solution

by:
neongrau earned 500 total points
ID: 8210966
Hi!

i haven't tested it but try this script:

<script language=javascript DEFER>
function bannerotate(p_strBannerset,p_lMax,p_lCount) {
  x = parseInt(bannerotate.arguments[2]);
  if ( isNaN(x) == true || x > p_lMax || x == 1 ) {
    p_lCount = 1;
    document.getElementById(p_strBannerset+p_lMax).style.display='none';
    document.getElementById(p_strBannerset+p_lCount).style.display='block';
  } else {
    document.getElementById(p_strBannerset+(p_lCount-1)).style.display='none';
    document.getElementById(p_strBannerset+p_lCount).style.display='block';
  }
  p_lCount++;
  window.setTimeout("bannerotate('"+p_strBannerset+"',"+p_lMax+","+p_lCount+")",1000);
}
</script>

<style>
.banner
{
position; absolute;
top 10px;
left: 10p;
display: none;
width: 468px;
height: 60px;
border: 1px solid black;
background: pink;
}
</style>

<body onLoad="bannerotate('blayer',4);bannerotate('layer',6)">

<div class=banner id="layer1">layer1</div>
<div class=banner id="layer2">layer2</div>
<div class=banner id="layer3">layer3</div>
<div class=banner id="layer4">layer4</div>
<div class=banner id="layer5">layer5</div>
<div class=banner id="layer6">layer6</div>


<div class=banner2 id="blayer1">layer1</div>
<div class=banner2 id="blayer2">layer2</div>
<div class=banner2 id="blayer3">layer3</div>
<div class=banner2 id="blayer4">layer4</div>
</body>

usage is to create a set of divs with setname+number
call the function in <body onLoad...
via "bannerotate('bannersetname',bannercount);"

regards
~neongrau
0
 

Author Comment

by:multisites
ID: 8214571
Great, neongrau, it does work. Thanks a lot. You are really worthy of the points. Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question