You need to sign in to do that
Don't have an account?
Mak One
How to iterate through each element in pageBlockTable?
I have to iterate through each element in pageBlockTable and if no element's checkbox is checked then I have to disable Submit Button in runtime without submitting the form.
Below is my snippet of Visualforce page:
The line:
var curr=document.getElementbyID('{!$Component.formId.pageBlockId.pageBlockTableId[i].headerId.checkBoxId}').value;
is having error: Unknown property 'StandardController.i'
Then how to get checked of each element in pageBlockTable.
What is the correct way rather than work around solution? Without changing pageBlockTable and without using any 3rd party tool.
<apex:form id="formId">
<apex:pageBlock id="pageBlockId">
<apex:pageBlockTable value="{!displayToSelect}" var="disp" id="pageBlockTableId">
<apex:column headerValue="Commercial Reference" style="text-align:center;">
<apex:outputLabel value="{!disp.cr.Field1__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputText value="{!disp.status}"/>
</apex:column>
<apex:column headerValue="Add This?" id="headerId">
<apex:inputCheckbox value="{!disp.check}" onChange="checkEnableDisable()" id="checkboxId"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:commandButton value="Submit" action="{!submitRecords}" disabled="{!disableSubmit}" id="submitId"/>
</apex:form>
<script>
checkEnableDisable(){
var allUnchecked=true;
var list=document.getElementbyID('{!$Component.formId.pageBlockId.pageBlockTableId}');
for (var i=0;i<list.length;i++){
var curr=document.getElementbyID('{!$Component.formId.pageBlockId.pageBlockTableId[i].headerId.checkBoxId}').value;
if (curr==true){
allunchecked=false;
}
}
document.getElementbyID('{!$Component.formId.submitId}').setAttribute('disabled',alluNchecked);
}
</script>
Below is my snippet of Visualforce page:
The line:
var curr=document.getElementbyID('{!$Component.formId.pageBlockId.pageBlockTableId[i].headerId.checkBoxId}').value;
is having error: Unknown property 'StandardController.i'
Then how to get checked of each element in pageBlockTable.
What is the correct way rather than work around solution? Without changing pageBlockTable and without using any 3rd party tool.
<apex:form id="formId">
<apex:pageBlock id="pageBlockId">
<apex:pageBlockTable value="{!displayToSelect}" var="disp" id="pageBlockTableId">
<apex:column headerValue="Commercial Reference" style="text-align:center;">
<apex:outputLabel value="{!disp.cr.Field1__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputText value="{!disp.status}"/>
</apex:column>
<apex:column headerValue="Add This?" id="headerId">
<apex:inputCheckbox value="{!disp.check}" onChange="checkEnableDisable()" id="checkboxId"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:commandButton value="Submit" action="{!submitRecords}" disabled="{!disableSubmit}" id="submitId"/>
</apex:form>
<script>
checkEnableDisable(){
var allUnchecked=true;
var list=document.getElementbyID('{!$Component.formId.pageBlockId.pageBlockTableId}');
for (var i=0;i<list.length;i++){
var curr=document.getElementbyID('{!$Component.formId.pageBlockId.pageBlockTableId[i].headerId.checkBoxId}').value;
if (curr==true){
allunchecked=false;
}
}
document.getElementbyID('{!$Component.formId.submitId}').setAttribute('disabled',alluNchecked);
}
</script>
How to access table values from that?