0

I have a Visualforce Page with some fields, all of which are check box fields. If I created record by selecting some check box fields only. But how should I filter the only selected fields in Visualforce Page?

How can I filter the selected fields only?

Here is my page:

<apex:page sidebar="false" controller="DataInsert">
 <apex:form >
     <div style="border:1px solid; width:200px;">
    <div style="height:30px;width:150px;margin-top:20px;margin-left:20px;

                     font-size:15px;color:blue;">
            Incident Fields 
         </div>
     <table>
         <tr>
             <td>
                 Imtpact
             </td>
             <td>
                 <apex:inputCheckbox value="{!impact}"/>
             </td>
             </tr>
             <tr>
             <td>
                 Incident_state
             </td>
             <td>
                <apex:inputCheckbox value="{!incident_state}"/>
             </td>
             </tr>
             <tr>
             <td>
                 Short_description
             </td>
             <td>
                <apex:inputCheckbox value="{!short_description}"/>
             </td>
             </tr>

             <tr>
             <td>
                 sys_id
             </td>
             <td>
                 <apex:inputCheckbox value="{!sys_id}"/>
             </td>
         </tr>
         <tr>
             <td>
                 Contact_type
             </td>
             <td>
                <apex:inputCheckbox value="{!contact_type}"/>
             </td>
             </tr>
             <tr>
             <td>
                 U_sftype
             </td>
             <td>
                <apex:inputCheckbox value="{!u_sftype}"/>
             </td>
             </tr>
             <tr>
             <td>
                 sys_updated_onONLast
             </td>
             <td>
                <apex:inputCheckbox value="{!sys_updated_onONLast}"/>
             </td>
             </tr>
         <tr >
             <td colspan="2" align="center">
                 <apex:commandButton value="INSERT" style="color:red;" action="{!doInsert}" />
             </td>
         </tr>
     </table>
     </div>

 </apex:form>

</apex:page>
0

You can easily check them in your controller using if condition. Here is once code sample for your reference.

public void yourmethod(){
 // some code here
 if(short_description){
   //its true so execute your code
}
if(impact){
//its true so execute your code
}
//Same for all checkbox.

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.