[dokuwiki] addEvent javascript question

  • From: "Martin Tschofen" <martin.tschofen@xxxxxxxxx>
  • To: "doku wiki" <dokuwiki@xxxxxxxxxxxxx>
  • Date: Mon, 22 May 2006 21:51:47 -0500

I'm trying to add an onchange event to dropdowns.

All dropdowns have the same class attached.

I created an addInitEvent call to a function that calls an addEvent
for all found dropdowns with that class:

function linkToPage(obj) {
      //for testing only
        alert(obj.value);
}

The addinitevent calls this function to assign the event to each select tag:
function installDDs() {
// Find all select with class 'url' and enable them
   if (!document.getElementsByTagName) return;
   var popups = document.getElementsByTagName("select");
   for (i=0;i<popups.length;i++) {
       var thisPopup = popups[i];
       if ((' '+thisPopup.className+' ').indexOf("url") != -1) {
           addEvent(thisPopup, 'change', function(){linkToPage(thisPopup)});
           //test if a popup was found
           alert('initialize '+thisPopup);
       }
   }
}

addInitEvent(function(){installDDs();});

When the page initially loads, I get the 'initialize...' message
indicating that it found an appropriate object.

But when I change the dropdown nothing happens, not even a javascript
error. I looked through
http://wiki.splitbrain.org/wiki:devel:javascript and the code to look
for any clues.

Am I useing addEvent wrong? I modeled if after the footnote javascript.
Am I passing the object itself into the event wrong?

Any pointer would be greatly appreciated.

TIA...martin
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: