469,323 Members | 1,601 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Why error in IE not Firefox?

Tell I'm stupid if you will.... the following works on Firefox but not
in IE (6) - gives an error

Line 16 Char 3
Illegal Assignment

<html>
<body>
<form name=f>
<input type=text name=inp>
&nbsp;
<input type=button value=convert onclick="conv();">
&nbsp;
<input type=text name=out>
</form>
<script type="text/javascript">
function conv()
{
f=document.forms[0].inp;
alert ("input"+ f.value);
}
</script>
</body>
</html>

Also, any good javascript debuggers available free of charge?
--

jeremy

Oct 26 '05 #1
2 1405
Jeremy wrote:
Tell I'm stupid if you will.... the following works on Firefox but not
in IE (6) - gives an error

Line 16 Char 3
Illegal Assignment

<html>
<body>
<form name=f>
IE makes the name of the form as a global variable, Firefox doesn't.
<input type=text name=inp>
&nbsp;
<input type=button value=convert onclick="conv();">
&nbsp;
<input type=text name=out>
</form>
<script type="text/javascript">
function conv()
{
f=document.forms[0].inp;
Here you create another global variable called 'f' that in IE conflicts
with the already declared f. It seems the form wins and the assignment
of the input reference is not achieved.

The simple solution is to include the keyword 'var' to make f a local
variable:

var f = document.forms[0].inp;

alert ("input"+ f.value);
}
</script>
</body>
</html>

Also, any good javascript debuggers available free of charge?

Use the javascript console in the Geko-based browsers (Firefox, Mozilla,
Netscape, et al).
--
Rob
Oct 26 '05 #2
In article <435f57e4$0$8658$5a62ac22@per-qv1-newsreader-
01.iinet.net.au>, RobG says...
Jeremy wrote:
Tell I'm stupid if you will.... the following works on Firefox but not
in IE (6) - gives an error

Line 16 Char 3
Illegal Assignment

<html>
<body>
<form name=f>


IE makes the name of the form as a global variable, Firefox doesn't.
<input type=text name=inp>
&nbsp;
<input type=button value=convert onclick="conv();">
&nbsp;
<input type=text name=out>
</form>
<script type="text/javascript">
function conv()
{
f=document.forms[0].inp;


Here you create another global variable called 'f' that in IE conflicts
with the already declared f. It seems the form wins and the assignment
of the input reference is not achieved.

Oh thanks very much for that.
<snip>
Also, any good javascript debuggers available free of charge?

Use the javascript console in the Geko-based browsers (Firefox, Mozilla,
Netscape, et al).


OK thanks I have played with these already - unfortunately when the
error only shows in IE.... :(
--

jeremy
Oct 26 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by debugger | last post: by
4 posts views Thread by gattaca8 | last post: by
3 posts views Thread by Brian A | last post: by
reply views Thread by Wayne Deleersnyder | last post: by
5 posts views Thread by Geoff Cox | last post: by
1 post views Thread by nancyisbell | last post: by
1 post views Thread by Joey | last post: by
2 posts views Thread by germ | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.