...

View Full Version : Randomizer issue



rightbrainer
12-11-2011, 06:53 PM
I had someone develop the javascript code to randomize the ads on my website: VillageOfManito dotcom and it worked great for many years.

The ads were all contained in the left hand column which were called into the page via ASP code.

Now I've been asked to split the ads into two columns, but when I divided the code and ads, the randomizer broke. See:
VillageOfManito dotcom /template.asp

You can also view the code for the columns here:
VillageOfManito dotcom /left_column.htm
VillageOfManito dotcom /right_column.htm

when I call up the individual columns (htm/javascript pages) by themselves, the randomizer works fine.

the "break" occurs when the asp page is opened, where the 2 htm/javascript pages are called into the main page... are they causing conflict with each other?

Old Pedant
12-11-2011, 07:48 PM
Well, for starters, your HTML code is illegal. You have *TWO* <body> tags in one page. Not legal. (And two <head> tags, which is also illegal, but usually doesn't cause a problem.)

So, yes, that code will never work as given. You have the same JavaScript functions declared twice. When you do that, only the *last* function declared does anything. The other one(s) is/are ignored.

Time for a complete rewrite.

You also have other illegal HTML in there. For example you have

<ul>
<font>
<li>

Not legal.

You *could* have


<font>
<ul>
<li>

But <font> is deprecated, anyway. Better to use a CSS style and simply apply it to all the <li>'s.

Example:


<style type="text/css">
ul.ads li { color: red; }
</style>
...
<ul class="ads">
<li>...

rightbrainer
12-11-2011, 08:00 PM
"You have the same JavaScript functions declared twice. When you do that, only the *last* function declared does anything. The other one(s) is/are ignored.

Time for a complete rewrite."

I was afraid of that. Thank you for your time and for your html issue pointers as well.

Old Pedant
12-11-2011, 08:12 PM
May I suggest something?

Since you are doing this from ASP, why not let ASP do the randomizing?

Or is your intention that order of the ads is shuffled from time to time while the page is being displayed?

If you only need them randomized when they first appear, I would do it all in ASP code. Much simpler.

And no need for the #include's, either.

Old Pedant
12-11-2011, 08:18 PM
Yeah, I looked more carefully at the JS code: You only need them randomly arranged when the page first appears. So clearly this could be more easily done in ASP code.

Also, a suggestion: For fairness, why not randomize the images on the left side and then put the images in *reverse order* on the right side? That is, only randomize once.

That way the sum of the positions of each ad is the same, totally fair distribution. And easy to code.

If you want to do this, post in the ASP forum and I'll show you how.

rightbrainer
12-12-2011, 12:17 AM
I've have done as you suggested and moved the issue to the ASP forum. Thank you for your time, it was a real day brightener when you posted the new replies and said you could help me with the ASP coding. I thought I was dead in the water before that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum