www.webdeveloper.com
Results 1 to 5 of 5

Thread: Display script not working in IE

  1. #1
    Join Date
    Jan 2010
    Location
    Perth
    Posts
    133

    Display script not working in IE

    Can someone explain why this is not working in IE and only in firefox. I believe it to be because of the if statement.

    PHP Code:
    function find(fi){

    var 
    table document.getElementById("incidenttable");
    var 
    arr table.getElementsByTagName("tr");
    for (
    0arr.lengthi++) {
       
    status arr[i].getAttribute("class");
            
    arr[i].style.display arr[i].style.display "";
         if(
    status !== fi && status !== "rower") {

       
    arr[i].style.display arr[i].style.display "none";
                           }
    }
    }


    </script>
    <h1 align=center>Incident Report Matrix - Online</h1>
    <div align="center"><table align="center" id="incident" width="40%">
    <tr>
    <td><input type="button" onClick="find('Application')" value="Application" /></td>
    <td><input type="button" onClick="find('System')" value="System" /></td>
    <td><input type="button" onClick="find('Network')" value="Network" /></td>
    <td><input type="button" onClick="find('Store')" value="Store" /></td>
    <td><input type="button" onClick="find('Other')" value="Other" /></td>
    </tr>
    </table></div>
    <table border=1 style="text-align:center" cellspacing=0 id="incidenttable" cellpadding=0 width="100%">
    <tr style="font-weight:bold;" class="rower">
    <td>Number</td><td>Date</td><td>System</td><td>Desc</td><td>Reported by</td><td>Impact</td><td>Status</td><td>Reason</td>
    </tr> 

  2. #2
    Join Date
    Jun 2007
    Posts
    667
    Quote Originally Posted by ericatekka View Post
    PHP Code:
       status arr[i].getAttribute("class"); 
    Avoid getAtribute/setAttribute unless you have no choice, which is rare.
    Try:
    Code:
    status = arr[i].className;
    What is the point of this repeated assignment?
    Code:
    arr[i].style.display = arr[i].style.display = "";
    Y_U U_G_A_E_U_ B_S_A_D_

  3. #3
    Join Date
    Jan 2010
    Location
    Perth
    Posts
    133
    That one there is to remove the previously set display = none tag.

    It basically reset anything that was previously done by the script.

    Thanks for the get attribute I will look at that.

  4. #4
    Join Date
    Jan 2010
    Location
    Perth
    Posts
    133
    Hey cool that works now. getAttribute must not be accepted by IE.

  5. #5
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by ericatekka View Post
    Hey cool that works now. getAttribute must not be accepted by IE.
    Don't precipitate. IE accepts getAttribute(). But for IE, class is a reserved word, so that IE uses another argument:getAttribute(className). To avoid an unnecessary double if conditional, in practice it is better to use the old DOM 0 syntax:

    element.className

    The same with style.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles