[B]Hi,
I have an index page which has 2 frames, view & editor.
Editor has a drop down menu (using select tag), i’m suppose to write a function to create a menu of view ids. I run the function in body tag using onload. not sure if it’s right. & I can’t figure out what is wrong with my code.
Here is part of editor page code.
Thanks in advance.[/B]
<head>
<script type = "text/javascript">
<!--
//This function gets a frame name and return an array of IDs in that frame.
function getElementIDs(frameName){
var allTags = newArray();
allTags = window.frames['frameName'].document.body.getElementsByTagName("*");
var ids = newArray();
for (var tg = 0; tg< allTags.length; tg++) {
var tag = allTags[tg];
if (tag.id) {
ids.push(tag.id);
}
}
return ids;
}
//create the drop down list, it gets the frame name and the select id
function addDropList(frameName,targetID){
var list = newArray();
list= getElementIDs(frameName);
var target= document.getElementById("targetID");
for(var i=0; i<list.length; i++){
var o = document.createElement("option");
o.value = list[i];
o.text = list[i];
target.add(o);
}
}
//it function is supposed to run when the page is loaded. It creates the
// drop list of view frame IDs.
function my_load(){
addDropList(view,sID);
}
//-->
</script>
</head>
<body onload="my_load();">
<form>
<p>
<label> Please choose an element to edit:
<select name = "IDs" id="sID" >
<option></option>
</select>
</label>
</p>
</form>
</body>