You need to sign in to do that
Don't have an account?
Disabling an inputField via JavaScript based on SelectList choice?
I've got a big spreadsheet-style input. in a pageBlock. I''ve tried making an asynchronous call to my controller and rerendering the page based on the field value, but this is painfully slow. I'd like to use JavaScript to disable/enable an inputField on a row once a selectList is chosen. Here's what I've got, and I can see that it's not throwing any errors in Chrome and referencing the correct value. Still, it does nothing! Any help?
Specifically, I need help passing the selected value from the selectlist "myList" to the JavaScript in the inpuField "value" and getting it to actually disable based on that argument.
<apex:pageBlockSection id="Calls" columns="1" collapsible="true" title="Calls" rendered="{!totalCalls > 0}"> <apex:outputPanel styleClass="tableContainer" layout="block"> <apex:pageBlockTable id="resultsIMC" value="{!calls}" var="n" cellPadding="4" border="1" styleclass="floatingHeaderTable"> <apex:column value="{!n.Client_Call_Time__c}" headerValue="Call Time"> </apex:column> <apex:column value="{!n.Nice_CallerID__c}" headerValue="Caller ID"> </apex:column> <apex:column value="{!n.Duration__c}" headerValue="Duration"> </apex:column> <apex:column headerValue="Disposition"> <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1" onChange="disableValue(this.value);"> <apex:selectOptions id="disposition" value="{!availablePick}" > </apex:selectOptions> </apex:selectList> </apex:column> <apex:column headerValue="Category"> <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c != 'Accept', true, false)}" multiselect="false" size="1" > <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters"> <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/> </apex:actionSupport> <apex:selectOptions value="{!availableCat}"/> </apex:selectList> </apex:column> <apex:column headerValue="Value" style="width:20px"> <apex:inputField id="value" value="{!n.Value__c}"> <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters"> <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/> </apex:actionSupport> <script> function disableValue(e) { if ( e == "Reject" ) { document.getElementById('{!$Component.value}').setAttribute("disabled","disabled"); } else { document.getElementById('{!$Component.value}').removeAttribute("disabled"); } } </script> </apex:inputField> </apex:column> </apex:pageBlockTable> </apex:outputPanel> </apex:pageBlockSection>
Remove <apex:actionsupport from inputfield,
you can get the value from selectlist to javascript by using disableValue(this.value) itself.
If you have any specific reason for having the actionsupport then please post your controller code also...will help to find the solution....
Please mark this as answer if its solve your problem
I tried that, but it doesn't seem to work.
Can you post your controller and VF code....
Here's what I ended up doing. I just removed the JavaScript since it doesn't seem like it'll work for inputFields. The problem is that the disabling occurs whenever the controller state is updated o the server, rather than handled at the page level. It's just slow.
Would still love to get the above code working, though.
Controller: