// Copyright 2001-2005 Interakt Online. All rights reserved. /* * dependent dropdown should create two objects : masterselect, only if it doesn't exist details select */ $DDN_GLOBALOBJECT = 'DependentDropdowns'; if (typeof window[$DDN_GLOBALOBJECT] == 'undefined') { window[$DDN_GLOBALOBJECT] = {}; } function MXW_DependentDropdown(detailSelect) { var originalElement = document.getElementById(detailSelect); if (typeof(originalElement.kt_uni_attached) == 'undefined') { originalElement.kt_uni_attached = true; } else { return; } this.detailSelect = originalElement; this.masterSelect = document.getElementById(WDG_getAttributeNS(this.detailSelect, 'triggerobject')); this.master = new MXW_MasterSelect(this.masterSelect); this.recordset = new JSRecordset(WDG_getAttributeNS(this.detailSelect, 'recordset')); this.fkey = WDG_getAttributeNS(this.detailSelect, 'fkey'); this.valuefield = WDG_getAttributeNS(this.detailSelect, 'valuefield'); this.displayfield = WDG_getAttributeNS(this.detailSelect, 'displayfield'); this.defaultValue = WDG_getAttributeNS(this.detailSelect, 'selected'); window[$DDN_GLOBALOBJECT][this.detailSelect.id] = this; window[$DDR_DEPENDENT_OBJ][this.masterSelect.id + '_' + this.detailSelect.id] = this; this.master.connectByName(this, 'updateMe'); this.initialize(); try {Kore.addUnloadListener(this.dispose, this);}catch(err){} } MXW_DependentDropdown_dispose = function() { try {Kore.removeUnloadListener(this.dispose, this);} catch(err) {} this.master.disconnectAllByName(this, 'updateMe'); try{delete window[$DDN_GLOBALOBJECT][this.detailSelect.id];}catch(err){} } MXW_DependentDropdown.prototype.dispose = MXW_DependentDropdown_dispose; function MXW_DependentDropdown_initialize() { this.defaultOptions = []; for (var i=0; i < this.detailSelect.options.length; i++) { Array_push(this.defaultOptions, { 'value': this.detailSelect.options[i].value, 'text': this.detailSelect.options[i].text }); } if (this.defaultValue) { if(this.recordset.find(this.valuefield, "=", this.defaultValue) ) { if (typeof window[$DDN_GLOBALOBJECT][this.masterSelect.id] == 'undefined') { WDG_setAttributeNS(this.masterSelect, "selected", this.recordset.Fields(this.fkey)); for (var i=0;i