Mock tests, Interview questions, Tutorials and Tech news
 
 
Home > Programming / tutorials > Button not disabled in Firefox and Chrome

Button not disabled in Firefox and Chrome

When you try to disable any button in your web application using this javascript function

document.getElementById(‘buttonId’).disabled=true;

You may find that it will work in IE but on Firefox and Chrome.

Reason:

From W3Scholl,

“Enabled” Property isn’t standard property of XHTML 4(It’s Microsoft standard.).

So the solution would be to add this piece of code

var obj = document.getElementById(‘buttonId”);
getLabel = function(elem){
if (elem.id && elem.id==”label”) {
elem.id = “disabledLabel”;
}
};
Dom.getElementsBy(getLabel ,’td’, obj);

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • IndianPad
  • Reddit
  1. August 30th, 2010 at 21:33 | #1

    It works for me but it does not show the button as grayed out . So the user does not know until and unless he clicks on button.

  2. August 30th, 2010 at 21:19 | #2

    document.getElementById(‘buttonId’).disabled=true;
    this javascript function works in my chrome 5.0.375.127 and firefox 3.6.8

    it can disable a button.

  1. No trackbacks yet.
Get Adobe Flash playerPlugin by wpburn.com wordpress themes