?
Solved

document.getElementById is not working in firefox and netscape

Posted on 2005-04-29
4
Medium Priority
?
269 Views
Last Modified: 2008-03-03
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
0
Comment
Question by:javagirip
3 Comments
 
LVL 7

Assisted Solution

by:wesbird
wesbird earned 120 total points
ID: 13897343
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
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 80 total points
ID: 13898066
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13899544
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spend far too much time on the web keeping up with the news: politics, the environment, computer stuff, the Experts Exchange. It's never-ending. But many of the most informative web pages are overwhelmed with noise: scrolling banners, flashing tex…
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 Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

850 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