document.getElementById is not working in firefox and netscape


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()?

Who is Participating?
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;

      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.  

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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.