Anonymoose
Anonymoose

Reputation: 2461

Disabling button in javascript not working in IE

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

Upvotes: 1

Views: 2862

Answers (4)

Dave
Dave

Reputation: 3621

Try

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

Upvotes: 2

Ravi Gadag
Ravi Gadag

Reputation: 15861

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);

Upvotes: 0

Ravi
Ravi

Reputation: 3200

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

Upvotes: 0

unarity
unarity

Reputation: 2445

 $("#StockPlates_btn").click(function(){
    $("#StockPlates_btn").preventDefault();
 })

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

Upvotes: 0

Related Questions