Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    9
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Randomizer issue

    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?
    Last edited by rightbrainer; 12-11-2011 at 06:58 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    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
    Code:
      <ul>
           <font>
               <li>
    Not legal.

    You *could* have
    Code:
        <font>
            <ul>
                <li>
    But <font> is deprecated, anyway. Better to use a CSS style and simply apply it to all the <li>'s.

    Example:
    Code:
    <style type="text/css">
    ul.ads li { color: red; }
    </style>
    ...
    <ul class="ads">
        <li>...
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    rightbrainer (12-11-2011)

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    9
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question answered

    "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.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    rightbrainer (12-12-2011)

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    rightbrainer (12-12-2011)

  • #6
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    9
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Issue moved to ASP forum

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •