Forum Moderators: open
$b[1][0] = "Agassiz Brewing";
$b[1][1] = "Bison Blonde Lager";
$b[1][2] = "Catfish Cream Ale";
$b[3][0] = "Alley Kat Brewing Company";
$b[3][1] = "Alley Kat Amber";
$b[3][2] = "Aprikat";
$b[4][0] = "Big Rock Brewery";
$b[4][1] = "Alberta Genuine Draft";
$b[4][2] = "Big Rock Honey Brown";
<script language="javascript">
<!--
var listData; // populate with list data
function buildList(index){
var theList = document.getElementById('secondList');
var theList.innerHTML = '';
for (var i=0;i<listData[index].length;i++){
var list_item = document.createElement('LI');
var list_text = document.createTextNode(listData[index][i]);
list_item.appendChild(list_text);
theList.appendChild(list_item);
}
}
//-->
</script>
This is untested code... and not the most efficient - but might point you in the right direction. You can have the onclick attribute of each LI in the first list call this function passing it the index of the array you want to populate the second list with (i.e. <li onclick="buildList(2)">My Name</li>).
<script language="javascript">
<!--
var listData; // populate with list data
function buildList(index){
var theList = document.getElementById('secondList');
var newInnerHTML = '';
for (var i=0;i<listData[index].length;i++){
newInnerHTML += '<li>';
newInnerHTML += listData[index][i]; // not escaped!
newInnerHTML += '</li>';
}
var theList.innerHTML = newInnerHTML;
}
//-->
</script>