4 Replies Latest reply on Nov 8, 2011 7:03 AM by c.pfaffenbichler

    onChange and DropDownList's - event not being dispatched

    JJ Fulks Level 1

      I can't get an onChange event to fire when making a ListItem selection in a DropDownList control. Am I doing something wrong? (I'm running XP Pro 32bit)

          

          
           var dlg = new Window('dialog');
           var pnl = dlg.add('panel');
           var myDDList1 = pnl.add('dropdownlist',undefined,['one', 'two', 'three'], {name: 'ddList1'});
           myDDList1.addEventListener('change', myFunction);
           var myDDList2 = pnl.add('dropdownlist',undefined,['one', 'two', 'three'], {name:'ddList2'});
           myDDList2.addEventListener('change', myFunction);
           var myDDList3 = pnl.add('dropdownlist',undefined,['one', 'two', 'three'], {name:'ddList3'});
           myDDList3.addEventListener('change', myFunction);
      
            function myFunction(ev)
           {
                var ddl = ev.target;
                var props = ddl.properties;
                if(props.hasOwnProperty('name'))
                {
                     switch(props.name)
                     {
                          case 'ddList1':
                              alert ('change made in ddList1');
                          break;
                          case 'ddList2':
                              alert ('change made in ddList2');
                          break;
                          case 'ddList3':
                              alert ('change made in ddList3');
                          break;
                     }
                }
            
                ddl = null;
                props = null;
           };     
           dlg.show();