SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to disable a table row...

    Hey all.

    I'm looking to disable/enable table rows on events but what I'm using is not working.

    The table row ID is "row1", so I use document.getElementById("row1").disabled = true;

    That doesn't work. I'm using FF, tested it in IE and the fields are "grayed" out but you can still enter text inside them.

    Any ideas?

  2. #2
    SitePoint Wizard jimbo_dk's Avatar
    Join Date
    May 2005
    Location
    Singapore
    Posts
    1,261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't really disable a table row, since it's not an input element. (not sure why IE chooses to do it for some reason). What you need to do is to make the row grey by using a css class, or alternatively document.getElementById("row1").style.backgroundColor = '#ccc'.
    Winners Respond. Losers React.
    Singapore Web Designer

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jimbo_dk View Post
    You can't really disable a table row, since it's not an input element. (not sure why IE chooses to do it for some reason). What you need to do is to make the row grey by using a css class, or alternatively document.getElementById("row1").style.backgroundColor = '#ccc'.
    So that means I'd have to disable each element "manually", right?

  4. #4
    SitePoint Wizard jimbo_dk's Avatar
    Join Date
    May 2005
    Location
    Singapore
    Posts
    1,261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If by that you mean give it the appearance of being disabled, then yes. You just need to change the style.
    Winners Respond. Losers React.
    Singapore Web Designer

  5. #5
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE also allows you to set the disabled attribute on other elements than form elements. You will automatically get this grayed out effect on tables etc. They seem to have implemented this half way though, since a disabled link can still be clicked on etc. The disabled attribute can be handy in a IE only intranet, but use jimbo_dk's solution instead (CSS solution) for a cross-browser solution.


Bookmarks

Posting Permissions

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