You need to sign in to do that
Don't have an account?
how to disable commandbutton from js
I'm trying to disable a commandbutton when any element of a form has been changed.
My js for detecting the form change is working ok, but the following js does not succeed in enablng or disabling the button.
<script type="text/javascript"> function enableCreateButton(state) { document.getElementById('{!$Component.thePage.theForm.thePageBlock.thePageBlockButtons.theCreateButton}').disabled = state; } </script>
Here's the markup:
<apex:commandButton value="Create Lead" action="{!createLead}" id="theCreateButton"/>
I can run enableCreateButton(true) or enableCreateButton(false) in the firebug console, and it has no effect. I can display document.getElementById('{!$Component.thePage.theForm.thePageBlock.thePageBlockButtons.theCreateButton}') in the console, and I see the component. I can see that running enableCreateButton changes the value of its disabled element.
What am I doing wrong here?
For one thing, I need to dynamically modify the class: