cenze
10-26-2006, 05:58 PM
Hi Everyone!
Here is a little script I'm working on:
function draw_list(array)
{
var output = "<ul id=\"nav\"><li>Select a lab:<ul>";
for (i=0; i < array.length; i++)
{
output += "<li><a href=\"#\" onclick=\"change_lab(" +
array[i][1] + ")\">" + array[i][0] + "</a></li>";
}
ouput += "</ul></li></ul>";
document.getElementById('dd_list').innerHTML = output;
}
Here is the array with list text and array names:
var period3 =
[
['Bone Joint and Skin Lab 01', lab01],
['Bone Joint and Skin Lab 02', lab02],
['Bone Joint and Skin Lab 03', lab03]
]
I am basically trying to create a dropdown list from array values.
The change_lab() function receives an array, which is 'contained' in array[i][1]. However, change_labs doesn't seem to be getting the array unless I explicitly plug it in like:
output += "<li><a href=\"#\" onclick=\"change_lab(lab02)\">" + period[i][0] + "</a></li>";
Can anyone tell me why, exactly, that this is the case?
I have a lot to learn about js mechanics...
Thanks very much!
Here is a little script I'm working on:
function draw_list(array)
{
var output = "<ul id=\"nav\"><li>Select a lab:<ul>";
for (i=0; i < array.length; i++)
{
output += "<li><a href=\"#\" onclick=\"change_lab(" +
array[i][1] + ")\">" + array[i][0] + "</a></li>";
}
ouput += "</ul></li></ul>";
document.getElementById('dd_list').innerHTML = output;
}
Here is the array with list text and array names:
var period3 =
[
['Bone Joint and Skin Lab 01', lab01],
['Bone Joint and Skin Lab 02', lab02],
['Bone Joint and Skin Lab 03', lab03]
]
I am basically trying to create a dropdown list from array values.
The change_lab() function receives an array, which is 'contained' in array[i][1]. However, change_labs doesn't seem to be getting the array unless I explicitly plug it in like:
output += "<li><a href=\"#\" onclick=\"change_lab(lab02)\">" + period[i][0] + "</a></li>";
Can anyone tell me why, exactly, that this is the case?
I have a lot to learn about js mechanics...
Thanks very much!