473,683 Members | 3,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getElementById ignored by Firefox

The following works in MSIE but not firefox.

I suspect it has something to do with the fact that the element I am
trying to access is not the "tid" which is the name of the DIV that is
passed to this javascript. The function is a "show/hide" for a form. I
want to ensure that any possible previously entered value is cleared
so the user starts with an empty field with focus.

I have tried to ways, with naming and getElementById but in both
cases any entry is left standing and the focus is not passed in
firefox, whilst both work fine in MSIE.

First attempt (with getElementById)

function InsertContentsh owgruppanm(tid) {
if( document.getEle mentById(tid).s tyle.display == "none") {
document.getEle mentById(tid).s tyle.display = "block";
document.getEle mentById("grant _ask").selected Index=0;
document.getEle mentById("tavfn mkas").value="" ;
document.getEle mentById("tavfn mkas").focus()
}

else {
document.getEle mentById(tid).s tyle.display = "none";
}
}
Second attempt (with name of form inserted)

function InsertContentsh owgruppanm(tid) {
if( document.getEle mentById(tid).s tyle.display == "none") {
document.getEle mentById(tid).s tyle.display = "block";
document.getEle mentById("grant _ask").selected Index=0;
document.prel_s vlmst_grpcol.ta vfnmkas.focus()
}
else {
document.getEle mentById(tid).s tyle.display = "none";
}
}
So obvious question. Whats the syntax for firefox?

Sep 5 '08 #1
3 2056
GarryJones meinte:
The following works in MSIE but not firefox.

I suspect it has something to do with the fact that the element I am
trying to access is not the "tid" which is the name of the DIV that is
passed to this javascript. The function is a "show/hide" for a form.
[snip]

DIVs don't have names. Forms and their elements have.

Anyway, your "problem" has been asked and answered hundreds of times
before. MSIE automatically (and wrongly) populates the id property of
elements with the same value of the name property, hence you can access
form elements with names via gEBI() - but only in IE. gEBI() needs
explicitly set (unique) ids. Otherwise resort to getElementsByNa me() -
note the plural.

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Sep 5 '08 #2
On 5 Sep, 23:13, Gregor Kofler <use...@gregork ofler.atwrote:
GarryJones meinte:
The following works in MSIE but not firefox.
DIVs don't have names. Forms and their elements have.
Still no go I am afraid....

Let me explain. The DIV has an ID and the first 2 rows of code either
display or hide the DIV which is correctly called by its id. Now, in
that DIV is a form. And on that form there are some elements which
have names. When the user clicks the link which fires this code it is
supposed to empty any previously entered value.

What I want is for the form to start with focus in the tavfnmkas
field. This field should be empty so any left over data from previous
viewings should be cleaned out when the button is clicked and the DIV
(with the form) toggles status "none" to status "block" and becomes
visible.

What these three "document.getEl ementsByName" lines should do is

document.getEle mentsByName("gr ant_ask").selec tedIndex=0; //SHOULD set
the selected option index to zero in a SELECT
document.getEle mentsByName("ta vfnmkas").value =""; //SHOULD removed any
previously entered data from the field tavfnmkas
document.getEle mentsByName("ta vfnmkas").focus () //SHOULD place focus
in the field tavfnmkas

"None of the above" is the result of my competence and understanding
of this. I am very gratefull of any further help anyone would like to
provide.

My latest attempt using getElementsByNa me
*************** *************** *************** **
function InsertContentsh owgruppanm(tid) {
if( document.getEle mentById(tid).s tyle.display == "none") {
document.getEle mentById(tid).s tyle.display = "block";
document.getEle mentsByName("gr ant_ask").selec tedIndex=0;
document.getEle mentsByName("ta vfnmkas").value ="";
document.getEle mentsByName("ta vfnmkas").focus ()
}

else {
document.getEle mentById(tid).s tyle.display = "none";
}
}

Any help appreciated!

Garry Jones
Sweden
Sep 5 '08 #3
GarryJones meinte:
document.getEle mentsByName("gr ant_ask").selec tedIndex=0;
document.getEle mentsByName("ta vfnmkas").value ="";
document.getEle mentsByName("ta vfnmkas").focus ()
getElementsByNa me() returns a collection (didn't I mention the plural?),
therefore you need document.getEle mentsByName(".. .")[0].propertyOrMeth od.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Sep 5 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1896
by: Dave Hammond | last post by:
Hi All, The following code works in IE but not Firefox. IE produces the expected "this is more text!" output, but Firefox produces "no more text". Any ideas why? <BODY> <FORM> <INPUT TYPE=HIDDEN NAME="moreText" VALUE="<PRE>This is more text!</PRE>">
1
3420
by: Muffinman | last post by:
Howdy, I've got here a sample of my function which is supposed to fade a certain piece of text to another colour. This line is then located in a for loop and it works pretty well in IE 6. However, in Firefox, and thus I assume it will be the same in Netscape and Mozilla, it gives a problem with the: getElementById('main_txt'). Due to that in setTimeout("",) it requires the "" signes and thus I can not use the same ones in the getElement...
5
31220
by: Derek Erb | last post by:
I am banging my head against the wall with this one. The following code snippets work perfectly fine in MSIE6. But produce an error in Firefox and do not work at all. BROWSER.HTM <HTML> .... <div class="Abb"> <h2 id="ABTit">BROWSER</h2> </div>
3
9260
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to work on FireFox or Netscape. What could be wrong? The function: function setActiveTab(tabNo) {
5
4332
by: Andrea | last post by:
I am trying to alter css using javascript as well as use the innerHTML function. I have pasted below 3 forms that access getElementById in slightly different ways (I wanted to rule out that it was the method.) All 3 work fine on IE but only work momentarily on Firefox. For example, one form has text that changes from red to black when the user clicks the button. In IE it changes. In Firefox it changes for a split second then goes back...
4
2657
by: the other john | last post by:
I came across a third party script I want to learn how to configure as well as learn more dhtml in the doing. I'm not much of a JS guy yet but I'm working on it. This script works fine in IE6 but is a dead fish in FireFox. There is no support offered on the site where it came from. I'd really appreciate help with this as it will not only to get it working but to learn how it all works so I can add it to my repertoire. Thanks!
1
1836
by: Zhang Weiwu | last post by:
Hello. I know a lot of different ways to write css that work for IE but ignored by Fx, but is there a way to let IE process XSLT but leaving Fx completely ignore the XSLT? The classic filter doesn't seem to work: <!--><?xml-stylesheet type="text/xsl" href="my.xsl"?><!--> The above seems to be ignored by both IE and Firefox P.S. In the beginning I thought finding something that works for IE but not
13
4941
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the internet. When I run Firebug on it, it says: document.getElementById("TICKER") has no properties TICKER_CONTENT = document.getElementById("TICKER").innerHTML; Here is the complete script:
1
2230
by: vikD | last post by:
Hello, I'm really bad at javascript but I managed to get the code below to work in IE but firefox gives this error... Error: document.getElementById.formall is undefined Basically use the script to update the display to the user depending on what they choose (qty, options, shipping etc.) I'm sure it's simple but I could really use a hand. Thanks!!
0
8568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8504
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8753
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6429
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2195
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.