document.getElementById is not working in firefox and netscape

Posted on 2005-04-29
Last Modified: 2008-03-03

I want to show the status bar image when the form is submitted until the next page loads, and  i am using <DIV> to do this, the following code perfectly works in the IE, but not in the FireFox.

in the body

<div id="statusMessage" style="display:none" class="textcenter"><img id="statusMessage"src="img/animatedstatus2.gif"></div>

The javascript:

function submitFilesFForm()
  document.getElementById('ListFiles').disabled = true;


<form method=POST name=filesform action="listfiles.html"  >
<div class="textcenter">
  <input type="SUBMIT" name = "ListFiles" value="View Files"onclick="submitFilesFForm()" > <br><br>  

The form is getting submitted properly, but the statuse bar is not getting displayed when the next page loads, Does this document.getElementById() work in Non IE browsers? ANy alternatives that I can use instead of this  document.getElementById()?

Question by:javagirip
    LVL 7

    Assisted Solution


          if (document.all&&document.getElementById) {
                navRoot = document.getElementById("nav");


    does work in ns and firefox.  

    I suspect that the code is bombing out in the line above where you're not using getElementByID to reference the DOM object.  Try adding an alert before and after the line   document.filesform.submit(); to see if they both display.  

    LVL 30

    Accepted Solution

    Important: make sure your spacing is correct in your html tags (no space before and after the "=" sign and a space before each tag attribute).

    You need to specify an ID if you want to use (firefox is more strict then IE when it comes to the standards):
      <input type="SUBMIT" name="ListFiles" id="ListFiles" value="View Files" onclick="submitFilesFForm()">

    Also, I would change the display property before submitting the form:
    function submitFilesFForm()
      document.getElementById('ListFiles').disabled = true;
    LVL 53

    Expert Comment

    statusMessage is being used as the id on two different elements.  The standards require that id be unique within a page.  IE which does not comply with the standards tries, successfully it would appear to resolve the erroneous declarations.  FF and NS instead quit executing the code when the hit the reference to the illegal id.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
    This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
    This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now