JuanRonline
JuanRonline

Reputation: 57

Enable checkbox on check of another checkbox

I have two columns in a table, with one checkbox in each column.

           <p:column headerText="#{msg['labels.ok']}" styleClass="center" style="width:40px;" id="acpCol">
                <p:selectBooleanCheckbox 
                    id="acpSel"
                    value="#{item.acept}"       
                    onchange="checkAcp(this);               
                    disabled="#{item.cancel}">
                </p:selectBooleanCheckbox>
            </p:column>

            <p:column headerText="#{msg['labels.cnx']}" styleClass="center" style="width:40px;" id="cnxCol" >
                <p:selectBooleanCheckbox
                    id="cnxSel" 
                    value="#{item.cancel}""
                    disabled="#{!item.acept}"
                    >
                </p:selectBooleanCheckbox>
            </p:column>

I need when first one is checked to enable the second one, but with javascript, i've not managed to do.

Upvotes: 1

Views: 813

Answers (1)

Joffrey Hernandez
Joffrey Hernandez

Reputation: 1846

I think you need to update the second one, something like this:

<p:column headerText="#{msg['labels.ok']}" styleClass="center" style="width:40px;" id="acpCol">
    <p:selectBooleanCheckbox id="acpSel" value="#{item.acept}" disabled="#{item.cancel}">
        <p:ajax update="cnxCol"/>  
    </p:selectBooleanCheckbox>
</p:column>

Upvotes: 2

Related Questions