1

I have method that after click print my document. I want after click disable my button. I use document.getElementsByName("btnGreenCard")[0].disabled = true; but is not working. Button isn`t disabled.

 PerformLongRunningOperation: function (path, operationId, messageSetterMethod) { messageSetterMethod(); $.blockUI.defaultAction(); var w = window.open(path + "?id=" + operationId, '_self', 'toolbar=0,location=0,menubar=0'); $.get('/Data/WaitToComplete/' + operationId + '?unique=' + this.GenerateGuid(), function (data) { $.unblockUI(); }); document.getElementsByName("btnGreenCard")[0].disabled = true; return false; } 

My button:

 <button type='submit' name="btnGreenCard" id="btnGreenCard" value="GreenCard" onclick="javascript:return Helpers.PerformLongRunningOperation('/PrintPolicy/GreenCard/','<%=Model.PolicyForPrintGuid%>',$.blockUI.setPdfMessage);"> Print</button> 

Any help or sugestion is welcome.

2 Answers 2

2

if you are using jquery you can use this snippet

$('button[name="btnGreenCard"]').prop('disabled', true); 

hope that will help you happy coding

Sign up to request clarification or add additional context in comments.

Comments

1

Use setAttribute:

document.getElementsByName("btnGreenCard")[0].setAttribute("disabled", true)

2 Comments

Works is blocked. I still have a question how to make the button grayed out?
Since it might have some styling already, you need to add custom css to the #btnGreenCard selector

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.