Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #810
| Newsgroups | alt.comp.lang.javascript, comp.lang.java.help |
|---|---|
| Subject | Re: Problem in other browsers than Internet Explorer |
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
| References | <1752b646-2ce0-47ab-b9a0-1f006a758aed@f39g2000prb.googlegroups.com> |
| Message-ID | <Xns9F167B0587951eejj99@194.109.133.246> (permalink) |
| Date | 2011-07-02 10:05 +0000 |
Cross-posted to 2 groups.
Ilya Shambat wrote on 02 jul 2011 in comp.lang.javascript:
> I have code that works when I use Internet Explorer, but does not work
> when I use Mozilla Firefox.
>
> The code is
>
> var textpassed = document.getElementById(fieldname).value;
>
> where fieldname is the name of the field as defined in the document.
"fieldname" has no meaning in html,
do you mean field like in
<input type='text' name ='a' id='b'>?
getElementById() needs the id of a tag, not the name.
Only clumsy IE seems to allow the name if an id is absent.
[better forget about that and never code for IE alone again.]
> Any other operations using similar code, such as
>
> alert ("In field " + document.getElementById(fieldname).name);
>
> returns valid results in Internet Explorer but not in Mozilla Firefox.
>
> Would anyone know the reasons for this, and is this possible to get
> around?
Use correct code and do not set your trust on the silly IE shortcuts:
document.getElementById(myId)
============
Understand that a name can be given to multiple tags, so ths will return
an array, and you would have to specify the member:
document.getElementsByName(myName)[3]
[This does not exist: getElementByName]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
Problem in other browsers than Internet Explorer Ilya Shambat <ibshambat@gmail.com> - 2011-07-01 20:58 -0700 Re: Problem in other browsers than Internet Explorer Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-07-01 21:13 -0700 Re: Problem in other browsers than Internet Explorer "Andy" <andy@NOSPAMmanyplay.com> - 2011-07-02 08:31 +0100 Re: Problem in other browsers than Internet Explorer "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-07-02 10:05 +0000 Re: Problem in other browsers than Internet Explorer Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-07-05 18:24 +0000
csiph-web