document.getElementById is not working in firefox and netscape

Hi,

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:

<script>
function submitFilesFForm()
{
  document.filesform.submit();
  document.getElementById('ListFiles').disabled = true;
  document.getElementById('statusMessage').style.display='block';
}

</script>

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

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

Thanks
javagiripAsked:
Who is Participating?
 
GrandSchtroumpfCommented:
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('statusMessage').style.display='block';
  document.filesform.submit();
  document.getElementById('ListFiles').disabled = true;
}
0
 
wesbirdCommented:
e.g.

      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.  

 
0
 
COBOLdinosaurCommented:
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.

Cd&
0
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.