Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/04/2002, 17:33
Avatar de urjose
urjose
 
Fecha de Ingreso: diciembre-2001
Mensajes: 5.286
Antigüedad: 23 años, 1 mes
Puntos: 1
Re: Help!! Error =(

var NS4 = (document.layers)?true:false;
var IE4 = (document.all)?true:false;

function _struct(child,childcaption,parent){
this.child = child;
this.childcaption = childcaption;
this.parent = parent;
}
function _addobject(child,childcaption,parent){
var obj = new _struct();
obj.child = child;
obj.childcaption = childcaption;
obj.parent = parent;
return(obj);
}
function insertEntry(child,childcaption,parent){
if(child.length > 0 ){
for(var i=0;i<this.length;i++)
if(this.items[I].child == child)
return;
this.items[this.length++] = _addobject(child,childcaption,parent);
}
}
function OptionCollection(){
this.length=0;
this.items = new Object();
this.Add=insertEntry
}

function clearSelect(oSelect){
var iCount=0;
if(!oSelect) return;
iCount = oSelect.options.length;
for(var i=0;i<iCount;i++){
if(IE4)
oSelect.options.remove(0);
else if(NS4)
oSelect.options[0]=null;
}
}
function addOptions(oSelect,olist,parent){
var elOption;
var idxSelect=0;

//check arguments.
if((!olist) || (!oSelect))return;
if(parent.length <= 0) return;

//now looop through all the list items only entering relevant options.
clearSelect(oSelect);

//add a blank list
elBlankOption = new Option();
elBlankOption.text = "";
if(NS4) oSelect.options[0] = elBlankOption
else if(IE4) oSelect.options.add(elBlankOption,0)

elBlankOption.value = "";
for(var i=0;i<olist.length;i++){
//only the child entries of the parent
if(olist.items[i].parent == parent){
elOption = new Option();
//now IE and NS have a different way to handle object creation.
if(NS4){
elOption.value = olist.items[i].child
elOption.text = olist.items[i].childcaption
oSelect.options[idxSelect] = elOption
}else if(IE4){
elOption.value = olist.items[i].child
elOption.text = olist.items.childcaption
oSelect.options.add(elOption,idxSelect)
Contin