/* * ComboBox * By Jared Nuzzolillo * * Updated by Erik Arvidsson * http://webfx.eae.net/contact.html#erik * 2002-06-13 Fixed Mozilla support and improved build performance * */ Global_run_event_hook = true; Global_combo_array = new Array(); Array.prototype.remove=function(dx) { if(isNaN(dx)||dx>this.length){self.status='Array_remove:invalid request-'+dx;return false} for(var i=0,n=0;i=0;i--) { this.options.remove(i) } this.options.length = 0; } function ComboBox_add() { var i,arglen; arglen=arguments.length for(i=0;i '+arr[i].text+' ' + ''; } str = str + strs.join("") + '' if(this.opslist){this.view.removeChild(this.opslist);} this.opslist = document.createElement("DIV") this.opslist.innerHTML=str; this.opslist.style.display='none'; this.opslist.className = "combo-list"; this.opslist.onselectstart=returnFalse; this.view.appendChild(this.opslist); } function ComboBox_toggle() { if(this.opslist) { if(this.opslist.style.display=="block") { this.opslist.style.display="none" } else { this.update(); this.build(this.options); this.view.style.zIndex = ++ComboBox.prototype.COMBOBOXZINDEX this.opslist.style.display="block" } } else { this.update(); this.build(this.options); this.view.style.zIndex = ++ComboBox.prototype.COMBOBOXZINDEX this.opslist.style.display="block" } } function ComboBox(cname,id) { if (document.getElementById) { x = document.getElementById(id); } else if (document.all) { x = document.all[id]; } else if (document.layers) { x = document.layers[id]; } /* if(arguments.length==0) { self.status="ComboBox invalid - no name arg" } */ this.name = cname; //arguments[0]; this.par = x ||document.body ; // arguments[1]||document.body this.view = document.createElement("DIV"); this.view.style.position='relative'; // absolute this.options = new Array(); this.expops = new Array(); this.value = "" this.build = ComboBox_build this.make = ComboBox_make; this.choose = ComboBox_choose; this.add = ComboBox_add; this.toggle = ComboBox_toggle; this.update = ComboBox_update; this.remove = ComboBox_remove; this.removeall = ComboBox_removeall; this.make() this.txtview = this.view.childNodes[0] this.valcon = this.view.childNodes[1] this.par.appendChild(this.view) Global_combo_array[Global_combo_array.length]=this; if(Global_run_event_hook){ComboBox_init()} } // given a divid // we are creating an object that is *attached* to that div. function ComboBox_attach(id) { if (document.getElementById) { x = document.getElementById(id); } else if (document.all) { x = document.all[id]; } else if (document.layers) { x = document.layers[id]; } this.name = id; this.par = x ; //arguments[1]||document.body this.view = x; // document.createElement("DIV"); // this.view.style.position='relative'; // absolute this.options = new Array(); this.expops = new Array(); this.value = "" this.build = ComboBox_build this.make = ComboBox_make; this.choose = ComboBox_choose; this.add = ComboBox_add; this.toggle = ComboBox_toggle; this.update = ComboBox_update; this.remove = ComboBox_remove; this.removeall = ComboBox_removeall; this.make() this.txtview = this.view.childNodes[0] this.valcon = this.view.childNodes[1] this.par.appendChild(this.view) // document.body.appendChild(this.view) Global_combo_array[Global_combo_array.length]=this; if(Global_run_event_hook){ComboBox_init()} } ComboBox.prototype.COMBOBOXZINDEX = 1001 //change this if you must // 1000 function ComboBox_init() { if (document.addEventListener) { document.addEventListener("keyup", ComboBox_handleKey, false ); document.addEventListener("mousedown", ComboBox_mouseDown, false ); } else if (document.attachEvent) { document.attachEvent("onkeyup", function () { ComboBox_handleKey(window.event); } ); document.attachEvent("onmousedown", function () { ComboBox_mouseDown(window.event); } ); } Global_run_event_hook = false; } function returnFalse(){return false} function ComboBoxItem(text,value) { this.text = text; this.value = value; } document.write('')