Hi all, looking for some clues please.

The following code works with one call to the function.
I want to repeat the same technique a second time on the same page.

I have commented out a second usage script and html.
Each works by them self, but one breaks when both are uncommented.
The first one lists both divs when first opened, and then works onchange.

Any solution would be much appreciated.


<html>
<head>

<script type="text/javascript">
function showListA(selectObj)
{
var listsA = new Array('cars', 'computers');
var selectedListIDA = selectObj.options[selectObj.selectedIndex].value;
var divObjA;

for(A=0; A<listsA.length; A++)
{
divObjA = document.getElementById(listsA[A]);
divObjA.style.display = (selectedListIDA==listsA[A]) ? '' : 'none';
}
return;
}

window.onload = function()
{
showListA(document.getElementById('listTypeA'));
return;
}
</script>


<!--
<script type="text/javascript">
function showListB(selectObj)
{
var listsB = new Array('colors', 'sports');
var selectedListIDB = selectObj.options[selectObj.selectedIndex].value;
var divObjB;

for(B=0; B<listsB.length; B++)
{
divObjB = document.getElementById(listsB[B]);
divObjB.style.display = (selectedListIDB==listsB[B]) ? '' : 'none';
}
return;
}

window.onload = function()
{
showListB(document.getElementById('listTypeB'));
return;
}
</script>
-->


</head>
<body>

<select name="listTypeA" id="listTypeA" onchange="showListA(this);">
<option value="cars">Cars</option>
<option value="computers">Computers</option>

</select>
<br />

<div id="cars">
<input type="checkbox" name="cars[]" value="Honda"> Honda<br />
<input type="checkbox" name="cars[]" value="Ford"> Ford<br />
<input type="checkbox" name="cars[]" value="Toyota"> Toyota<br />
</div>

<div id="computers">
<input type="checkbox" name="computers[]" value="Dell"> Dell<br />
<input type="checkbox" name="computers[]" value="HP"> HP<br />
<input type="checkbox" name="computers[]" value="Alienware"> Alienware<br />
</div>

<br /><br />

<!--
<select name="listTypeB" id="listTypeB" onchange="showListB(this);">
<option value="colors">Colors</option>
<option value="sports">Sports</option>
</select>
<br />

<div id="colors">
<input type="checkbox" name="colors[]" value="Yellow"> Yellow<br />
<input type="checkbox" name="colors[]" value="Green"> Green<br />
<input type="checkbox" name="colors[]" value="Blue"> Blue<br />
</div>

<div id="sports">
<input type="checkbox" name="sports[]" value="Football"> Football<br />
<input type="checkbox" name="sports[]" value="Baseball"> Baseball<br />
<input type="checkbox" name="sports[]" value="Hockey"> Hockey<br />
</div>
-->


</body>
</html>