SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an asp:Gridview control called gvComments that uses the following Javascript to show/hide table rows. If the expand/collapse button is clicked, a string (EventID) is passed to the function and all rows with that match the GV's bound field EventID should toggle. If I use alert on CommentRows[i].EventID in the loop it says its undefined, but CommentRows.length is correct. In Firebug it contains the value that's expected however it never passes the condition in the first if statement. I tried CommentRows[i]["EventID"] also and that didn't work.

The kicker is that it works in IE. How can I get this to work in FF?

Thank you.

*edit: This is in a MOSS 2007 custom web part

function ExpandCollapse(EventID) 
    var CommentRows = document.getElementById(gvComments).getElementsByTagName('TR');

    for (var i = 0; i < CommentRows.length; i++) {
        if (CommentRows[i].EventID == EventID) {
            if (CommentRows[i].style.display == 'none' || CommentRows[i].style.display == '') {
                if (navigator.appName == 'Microsoft Internet Explorer') {
                    CommentRows[i].style.display = 'block';
                else {
                    CommentRows[i].style.display = 'table-row';
            else {
                bCollapse = true;
                CommentRows[i].style.display = 'none';
share|improve this question
up vote 0 down vote accepted

Try using the getAttribute function:



share|improve this answer
getAttribute works. Thank you so much. – David King Oct 10 '11 at 19:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.