Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / March 2006



Tip: Looking for answers? Try searching our database.

enumerator not working in firefox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
toldyouso - 31 Mar 2006 00:05 GMT
The following script works in IE but in Firefox errors with the msg
Enumerator is not defined.
<html>
    <head>
        <meta name="vs_defaultClientScript" content="JavaScript">
        <script language="javascript">
<!--
function Recalc(){
var objHidden;
var objControl;
var objLabel;
var n = 0;
var sName;
var e = new Enumerator(document.getElementsByName("txt"));
while(!e.atEnd()){
        alert(e.item().value);
        e.moveNext();
    }
};

//-->
        </script>
        <script id="clientEventHandlersJS" language="javascript">
<!--

function Button1_onclick() {
return Recalc();
}

//-->
        </script>
    </head>
    <body>
        <form>
            <INPUT id="Text5" type="text" name="txt">
            <INPUT id="Text4" type="text" name="txt">
            <INPUT id="Text2" type="text" name="txt">
            <INPUT id="Text3" type="text" name="txt">
            <INPUT id="Text1" type="text" name="txt">
            <INPUT id="Button1" type="button" value="Button" name="Button1"
language="javascript" onclick="return Button1_onclick()">
        </form>
    </body>
</html>
Ian Collins - 31 Mar 2006 00:36 GMT
> The following script works in IE but in Firefox errors with the msg
> Enumerator is not defined.

Where have you defined it?

Signature

Ian Collins.

toldyouso - 31 Mar 2006 00:42 GMT
Do I have to define Enumerator, isn't part of the javascript language?
I didn't define it for IE...
Thomas 'PointedEars' Lahn - 31 Mar 2006 00:55 GMT
> Do I have to define Enumerator,

No.

> isn't part of the javascript language?

If you mean (Netscape) JavaScript, then no.

> I didn't define it for IE...

IE uses (Microsoft) JScript.

PointedEars
Thomas 'PointedEars' Lahn - 31 Mar 2006 00:53 GMT
^^^^^^^^^
Who?

> The following script works in IE but in Firefox errors with the msg
> Enumerator is not defined.

Enumerator is defined in Microsoft JScript (primarily to facilitate
interaction with other MS software, such as ADO), not in JavaScript.

See also <URL:http://pointedears.de/scripts/es-matrix>.

> [...]
>               <script language="javascript">

 <script type="text/javascript">

See <URL:http://validator.w3.org/>.

> <!--

Nonsense.  Search the archives for "comment" and the like.

> [...]
> var e = new Enumerator(document.getElementsByName("txt"));
> while(!e.atEnd()){
>               alert(e.item().value);
>               e.moveNext();
>       }

While it would be possible to write an Enumerator implementation for
JavaScript, the following is easier and works in IE-based UAs, too:

 var e = document.getElementsByName("txt");
 for (var i = 0, len = e.length; i < len; i++)
 {
   alert(e[i].value);
 }

See also <URL:http://pointedears.de/scripts/test/whatami#inference>.

> };

I doubt there is a point in ending a FunctionStatement with a `;', besides
the fact that it is indeed a statement.  It rather helps to confuse a
standalone FunctionStatement with a FunctionExpression in an assignment.

> //-->

Nonsense.

>               </script>
>               <script id="clientEventHandlersJS" language="javascript">

Utter nonsense.  The (X)HTML `script' element has no `id' attribute (by
default), nor would it be necessary here.

> [...]
>                       <INPUT id="Text1" type="text" name="txt">

type="text" is redundant, that is the default attribute value for this
element.

>                       <INPUT id="Button1" type="button" value="Button" name="Button1"
> language="javascript" onclick="return Button1_onclick()">

The (X)HTML `input' element has no `language' attribute (by default).
Again, the `id' attribute does not strike me as being necessary here.

Your indentation sucks.

PointedEars
toldyouso - 31 Mar 2006 14:29 GMT
Thanks for the info and the sweet criticism.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.