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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A_lot_of_divs.innerHTML="";

    Hi,

    I could do:

    d1.innerHTML="";
    d2.innerHTML="";
    d3.innerHTML="";

    But I like using an array because of the quantity of divs, like:

    var v1,v2,v3;
    v1=new Array("d1","d2","d3");
    v2=v1.length;
    for(v3=0;v3<v2;v3++)
    {
    v1[v3].innerHTML="";
    }

    Unfortunately the last isn't working, why?

    Thanks for Your time,
    Jerome

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    See if this example helps you:
    Code:
    <script type="text/javascript">
    <!--//
    function newSpan(span) {
    for(i=1; i<4+1; i++)
    document.getElementById('span'+[i]).innerHTML = span.options[span.selectedIndex].value
    }
    
    //-->
    </script>
    </HEAD>
    
    <BODY>
    Span 1 color is <b><span id="span1"></span></b><br />
    Span 2 color is <b><span id="span2"></span></b><br />
    Span 3 color is <b><span id="span3"></span></b><br />
    Span 4 color is <b><span id="span4"></span></b><br />
    <br /><br />
    <form name="form1">
    <select onChange="newSpan(this)">
    <option value="">--- Pick your favorite color ---</option>
    <option value="Red">Red</option>
    <option value="Blue">Blue</option>
    <option value="Green">Green</option>
    <option value="Yellow">Yellow</option>
    </select>
    .....Willy


  •  

    Posting Permissions

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