Creating a random.

Discussion in 'JavaScript' started by martinvidic, Dec 14, 2008.

  1. #1
    Hello.

    Maybe somebody can help we with this or give me a link to a tutorial.
    I am using div tags to sort the my ad-codes at the end of my html files.

    <div id='ads_code_1' style='display:none;'>
    <!-- Ad Code 1 -->
    </div>
       <script language="JavaScript">
        div1 = document.getElementById('adspace1');
        div2 = document.getElementById('ads_code_1');
        div1.innerHTML = div2.innerHTML;
        div2.innerHTML = "";
       </script>
    
    <div id='ads_code_2' style='display:none;'>
    <!-- Ad Code 2 -->
    </div>
       <script language="JavaScript">
        div1 = document.getElementById('adspace2');
        div2 = document.getElementById('ads_code_2');
        div1.innerHTML = div2.innerHTML;
        div2.innerHTML = "";
       </script>
    Code (markup):
    Now I want to create a 3rd adcode and alternate 2 & 3 randomly
    <!-- Ad Code 2 --> and <!-- Ad Code 3 -->
    So that only one of the two shows up.
    Does anybody have an idea how to do that.

    Thanx and best regards
    M.V.
     
    martinvidic, Dec 14, 2008 IP
  2. budster

    budster Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    budster, Dec 15, 2008 IP