+ Start a Discussion

Collecting boolean values from check boxes

My Asset objects have a boolean field called Opt_Out__c.


A single account can have multiple Asset objects.


I need to list each Asset object's Opt_Out__c field as a checkbox

and be able to update each Asset object's Opt_Out__c field.



Any suggestions to get this to work?


The page shows nicely, but how can I capture the selected ID for each Asset object.

Keep in mind that if an Account previously decided to 'opt out,' the check box should be selected

when the page loads!


VisualForce: Not sure which pageBlockSectionItem I should go with?

<!-- in this one, how do I get the id for the Asset object?-->	
<apex:pageBlockSectionItem >
                        <apex:outputPanel >
                            <apex:dataTable value="{!assets}" var="a">
                                    <apex:column >
                                        <apex:outputField value="{!a.Name}" />
                                    <apex:column >
                                        <apex:facet name="header">Opt Out</apex:facet>
                                        <apex:inputCheckbox value="{!a.Opt_Out__c}" />
     <!-- in this one, how do set the check box as selected, if need be, for the Asset object?-->                    
                        <apex:pageBlockSectionItem >
                            <apex:outputPanel id="thePanel">
                                <apex:outputLabel value="Select the items you would like to receive:" />
                                <apex:selectCheckboxes value="{!assetsToSave}"

                                    <apex:selectOptions value="{!options}" />

Use the first pageBlockSectionItem, and update 'assets' List variable when user clicks 'Save' (or whatever button you have).