Connecting Tech Pros Worldwide Help | Site Map

enumerator not working in firefox

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 30th, 2006, 10:15 PM
toldyouso
Guest
 
Posts: n/a
Default enumerator not working in firefox

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>


  #2  
Old March 30th, 2006, 10:45 PM
Ian Collins
Guest
 
Posts: n/a
Default Re: enumerator not working in firefox

toldyouso wrote:[color=blue]
> The following script works in IE but in Firefox errors with the msg
> Enumerator is not defined.[/color]

Where have you defined it?

--
Ian Collins.
  #3  
Old March 30th, 2006, 10:55 PM
toldyouso
Guest
 
Posts: n/a
Default Re: enumerator not working in firefox

Do I have to define Enumerator, isn't part of the javascript language?
I didn't define it for IE...

  #4  
Old March 30th, 2006, 11:05 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default Re: enumerator not working in firefox

toldyouso wrote:
^^^^^^^^^
Who?
[color=blue]
> The following script works in IE but in Firefox errors with the msg
> Enumerator is not defined.[/color]

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>.
[color=blue]
> [...]
> <script language="javascript">[/color]

<script type="text/javascript">

See <URL:http://validator.w3.org/>.
[color=blue]
> <!--[/color]

Nonsense. Search the archives for "comment" and the like.
[color=blue]
> [...]
> var e = new Enumerator(document.getElementsByName("txt"));
> while(!e.atEnd()){
> alert(e.item().value);
> e.moveNext();
> }[/color]

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>.
[color=blue]
> };[/color]

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.
[color=blue]
> //-->[/color]

Nonsense.
[color=blue]
> </script>
> <script id="clientEventHandlersJS" language="javascript">[/color]

Utter nonsense. The (X)HTML `script' element has no `id' attribute (by
default), nor would it be necessary here.
[color=blue]
> [...]
> <INPUT id="Text1" type="text" name="txt">[/color]

type="text" is redundant, that is the default attribute value for this
element.
[color=blue]
> <INPUT id="Button1" type="button" value="Button" name="Button1"
> language="javascript" onclick="return Button1_onclick()">[/color]

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
  #5  
Old March 30th, 2006, 11:05 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default Re: enumerator not working in firefox

toldyouso wrote:
[color=blue]
> Do I have to define Enumerator,[/color]

No.
[color=blue]
> isn't part of the javascript language?[/color]

If you mean (Netscape) JavaScript, then no.
[color=blue]
> I didn't define it for IE...[/color]

IE uses (Microsoft) JScript.


PointedEars
  #6  
Old March 31st, 2006, 12:45 PM
toldyouso
Guest
 
Posts: n/a
Default Re: enumerator not working in firefox

Thanks for the info and the sweet criticism.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.