ASP.NET + javascript: can't recognize form elements?

I am trying to access form elements in order to hide show div tags, the hide show part is easy but I keep getting a null reference.. it doesn't see my form!

When I write out document.forms.length  the resulting value is 0!!

when i write out elem.id after it is set, it will print out the appropriate element id that I had passd in.. so why does it sometimes know the element is there but can not find my form name?

javascript:

      function ShowConfiguration(id)
  {
         
      var elem = self.document.getElementById(id);
        var formElements = document.frmQuery.elements; //  becomes null.
 
     
      for(var i=0; i <  formElements.length; i++) //errors here saying formElements is null
        {
                  document.writeln(formElements[i].id);
            
            if(formElements[i] != null && formElements[i].substring(0,3)=="mnu")
            {
                  document.writeln(formElements[i].id);
                  if(elem.id == formElements[i].id)
                  {
                        //elem.style.display = 'block';
                        //elem.style.visibility = 'visible';
                        elem.style.display ='none';      
                        elem.style.visibility ='hidden';
                  }
                  else
                  {
                        formElements[i].style.display = 'block';
                        formElements[i].style.visibility = 'visible';
                        //elem.style.display ='none';      
                        //elem.style.visibility = 'hidden';
                  }
            }
      }
  }


parts of html:

<body>
            <form name="frmQuery" method="post" action="mainChart.aspx" id="frmQuery">

this form has some nested div tags who's id's will be passed by the onclick event of other buttons.


button code:
<TD><A class="menuLink" id="hypDataPullTimes" onclick="javascript:ShowConfiguration('mnuTransferTimes');"
                                                href="#">Data Pull Times</A>
                                    </TD>

LVL 1
bswiftlyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bswiftlyAuthor Commented:
well I stared at that solution for a day and decided to do a work around.. definately not a scalable piece of javascript but this is it:

And I'm not sure why I had to put this at the end outside of all the HTML, but i got different results outside the HEAD tag as to within it. I thought Head Tag code was rendered first ?  ah well.. I'll leave this question open in case anyone can substitude mnuElems.length in the following code for document.formName.elements, and then you will get points.    Remember..this is asp.net...which is I think the big problem here.. damn M$.

 function ShowConfiguration(id)
{        
      var elem = document.getElementById(id);
      var mnuElems = ["mnuTransferTimes","mnuSingleRetId"];
      var tmpElem;
      for(var i = 0; i<mnuElems.length;i++)
      {
            tmpElem = document.getElementById(mnuElems[i]);
            if(tmpElem)
            {
            tmpElem.style.display ='none';      
            tmpElem.style.visibility ='hidden';
            }
      }
       elem.style.display = 'block';
       elem.style.visibility = 'visible';
}

0
moduloCommented:
Closed, 50 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

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.