I have a visualforce page wherein I have to control two input boxes and one picklist field with a single checkbox. The idea is that input boxes must be both disabled when checkbox is selected, while input boxes must be enabled when checkbox is not selected. Also, with the same checkbox, picklist field must be enabled when checkbox is selected, while it must be disabled in default wherein checkbox is not selected.
I tried this with the first input box, and it is working. So I assigned same id to the second input box, but there's this error:
Duplicate ids have been detected
I know that ids per element must be unique, so I assigned another id to the second one.
As for the picklist field I am still not sure how since this is a different tag.
But how can I control these in a single checkbox while ids per input box differ?
Also, I would like to clarify that these three fields are all in one pageblockTable, but with different behavior based on the selection of checkbox.
portion in visualforce page
//portion to disable
<apex:inputText id="txt1" value="{!a.Text1__c}" html-placeholder="0"/>
<apex:inputText id="txt2" value="{!a.Text2__c}" html-placeholder="0"/>
<apex:selectList id="re" value="{!a.Picklist__c}">
//picklist values are controlled by a method in a controller
<apex:selectOptions value="{!picklistValues}"/>
</apex:selectList>
//checkbox portion
<apex:inputcheckbox id="Box" value="{!a.Box__c}" onclick="disableText(this.checked, '{!$Component.frmId.pbId.pbSecId.pbTableId.txt1}');"/>
//javascript portion
<script>
function disableText(value, inputId) {
document.getElementById(inputId).disabled = value;
}
</script>