Hi,

> var dropList = document.getElementsByClassName("dropdown","assign");

getElementsByClassName[1][2] returns a NodeList, not an Array.
Enumerable#each is mixed into arrays.  I suspect if you change that
to:

var dropList = $A(document.getElementsByClassName
("dropdown","assign"));

...it'll start working reliably cross-browser.  You might also
consider using some of Prototype's nifty functions like $$[3].

> Why does it load in IE, but not in FF?

Prototype provides an implementation of
document.getElementsByClassName on browsers that don't support it, but
leaves it alone if they do.  Prototype's implementation returns an
array (instead of a NodeList), and so it'll have Enumerable#each.  FF
has had this function a long time, so you get the version that returns
a NodeList, which doesn't have #each.  IE still doesn't have it, so it
ends up with Prototype's implementation, which does.

BTW, somewhat OT, but:

> var dropList = document.getElementsByClassName("dropdown","assign");

I'm not familiar with a version of getElementsByClassName that takes
multiple arguments[1][2].  (That could just be my ignorance.)  If
you're looking for elements that have both "dropdown" and "assign" as
classes, you'd want document.getElementsByClassName("dropdown assign")
not document.getElementsByClassName("dropdown","assign").  I wouldn't
be surprised to find that the second argument is being ignored by most
(or all) implementations.  It's certainly being ignored by
Prototype's.

[1] http://www.w3.org/TR/html5/dom.html#dom-document-getelementsbyclassname
[2] https://developer.mozilla.org/en/DOM/document.getElementsByClassName
[3] http://prototypejs.org/api/utility/dollar-dollar

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Jul 3, 1:39 am, michaeljcole <michaelcole....@gmail.com> wrote:
> Hi, I've inherited a prototype.js application, and I'm getting this
> error in FF3.0.  It works in IE8.  I've looked for the solution but
> can't figure it out.
>
> dropList.each is not a functionhttp://localhost/www/js/assign.js
> Line 8
>
> Why does it load in IE, but not in FF?
>
> Here is the html:
>
> <head>
> <script src="/www/js/prototype.js" type="text/javascript">
> <script src="/www/js/assign.js" type="text/javascript">
> </head>
> <body>Stuff</body>
>
> Here is assign.js:
>
> // hook this into onload using Prototype
> Event.observe(window,'load',dropListChange);
>
> // this function happens once on page load.
> function dropListChange() {
>   var dropList = document.getElementsByClassName("dropdown","assign");
>
>   dropList.each( function(listName) {
>     alert('hello world');
>     listName.onchange = sendChange;
>   });
>
> }
>
> function sendChange() {
>   var idName = this.id;
>   var newVal = this.value;
>   new Ajax.Request(endpoint, {
>     asynchronous: true,
>     method: "get",
>     parameters: "id=" + idName + "&v=" + newVal,
>     onSuccess: receiveChange,
>     onError: showError
>   });
>   if (newVal == -1) {
>     alert("If you wish to assign this survey to multiple users, you
> must assign subsections of it to individual users.");
>   }
>
> }
>
> function receiveChange(xhr) {
>   var respData = eval(xhr.responseText);
>   respData.each(function(list) {
>     if ($(list.elem)) {
>       $(list.elem).value = list.userid;
>     }
>   });
>
> }
>
> function showError(xhr) {
>   alert("Ajax error in assign.js");
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to