P
Phil Powell
Code:
function populateWithPics(folder) {
if (folder.value != '') {
monthIndex = folder.name.substring(folder.name.indexOf("'") + 1,
folder.name.indexOf('\]') - 1);
indexArray = folder.value.split('|');
index = indexArray[0];
if (!isNaN(index)) {
for (i = 0; i < picsArray[index].length; i++) {
document.calendarPicForm.elements['pics\[' + monthIndex +
'\]'].options[i + 2].value = picsArray[index][i];
document.calendarPicForm.elements['pics\[' + monthIndex +
'\]'].options[i + 2].text = picsArray[index][i];
}
}
}
}
The preceeding code is going to populate a dropdown named pics['0'] or
pics['5'] or pics['digit between 0 and 11'] with contents found in
picsArray[0] or picsArray[5], etc.
However upon attempt to do so I am getting the following error:
"document.calendarPicForm.elements['....'] is null or not an object"
Here is the script for the dropdown (an example, since there are 12 of
them to choose from):
Code:
<select name=pics[2]>
<option value="">
Choose a picture to display for the month of Mars:
</option>
<option value="">-------------------------------------------</option>
</select>
And picsArray is a 2-dim TCL-generated server-side array:
Code:
<script type="text/javascript">
<!--
picsArray[0] = new Array(7);
picsArray[0][0] = '/images/bands/Crimson_Moonlight.jpg';
picsArray[0][1] = '/images/bands/Crimson_Thorn.jpg';
picsArray[0][2] = '/images/bands/Extol.JPG';
picsArray[0][3] = '/images/bands/Lengsel.jpg';
picsArray[0][4] = '/images/bands/Vaakevandring.jpg';
picsArray[0][5] = '/images/bands/Zane_Matthews_04.jpg';
picsArray[0][6] = '/images/bands/vaakevandring2.jpg';
//-->
</script>
Bottom line: I want to populate a corresponding dropdown with a
corresponding 2-dim array upon selecting something from one of 12
dropdowns. The function fails due to the structure of of the form
element, so I am not sure what to do at this point, so I need help
again.
Thanx
Phil