1

I have a requirement to disable a button when no value is found for a certain object. This code works in FF and the button is greyed out. It doesn't work in IE however.

Here is my code:

if(c4Obj.getValueByName("Combined_Order",1)=="")  
    $("#StockPlates_btn").attr('disabled', true)
else 
    $("#StockPlates_btn").attr('disabled', false);

Thank you for your time

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Anonymoose
  • 2,389
  • 6
  • 36
  • 69

4 Answers4

2

Try

if(c4Obj.getValueByName("Combined_Order",1)=="")  
    $("#StockPlates_btn").attr('disabled', 'disabled')
else 
    $("#StockPlates_btn").removeAttr('disabled');
Nope
  • 22,147
  • 7
  • 47
  • 72
Dave
  • 3,581
  • 1
  • 22
  • 25
0
 $("#StockPlates_btn").click(function(){
    $("#StockPlates_btn").preventDefault();
 })

Try this. This will prevent click event when you click on it.

unarity
  • 2,339
  • 2
  • 21
  • 17
0

As Dave mentioned it should be disabled equals disabled for an option to be disabled in HTML.

The disabled attribute is not supported in IE, prior version 8.

Reference: http://www.w3schools.com/tags/att_option_disabled.asp

Ravi
  • 3,132
  • 5
  • 24
  • 35
0

may be you are using jQuery pre 1.6.1 version, which was why attr for disabled wasn't working quite right (for older IE).. by busing prop you can achive the task easily
try like this

if(c4Obj.getValueByName("Combined_Order",1)=="")  
    $("#StockPlates_btn").prop('disabled', true)
else 
    $("#StockPlates_btn").prop('disabled', false);
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83