...

View Full Version : A_lot_of_divs.innerHTML="";



Jerome
12-30-2003, 02:14 PM
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

Willy Duitt
12-30-2003, 02:28 PM
See if this example helps you:

<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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum