?
Solved

Text Banners - II

Posted on 2003-03-20
3
Medium Priority
?
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

765 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