0

I have checkbox for each row.. I want to pass the multiple checkbox value from VF page to controller..

Can you please help me out.. I am new to salesforce. I am not sure how to do that..

SOmeone told me to use Wrapper class But Still no luck..

Can anyone pls help me out here..

   <apex:PageBlock title="Matching Clozers to Accept"> 
    <apex:form id="sendMailToOther">
        <table style="width:100%"> 
            <tr> 
                <th>Name</th> 
                <th>Deal</th> 
                <th>Experience</th> 
                <th>Location</th> 
                <th>Schedule Meeting
                    <br/>
                    Select all <input type="checkbox" value="allCheck"/>
                </th> 
            </tr> 
            <tr> 
                <td>Customer Name</td> 
                <td>Deal Info</td> 
                <td>5 years</td> 
                <td>London</td> 
                <td> 
                    <input type="checkbox" value="singlecheck"/>
                </td> 
            </tr> 
            <tr> 
                <td>Customer Name</td> 
                <td>Deal Info</td> 
                <td>5 years</td> 
                <td>London</td> 
                <td> 
                    <input type="checkbox" value="singlecheck"/> 
                </td> 
            </tr> 
            <tr> 
                <td>Customer Name</td> 
                <td>Deal Info</td> 
                <td>5 years</td> 
                <td>London</td> 
                <td> 
                    <input type="checkbox" value="singlecheck"/>
                </td> 
            </tr> 
            <tr> 
                <td>&nbsp;</td> 
                <td>&nbsp;</td> 
                <td>&nbsp;</td> 
                <td>&nbsp;</td> 
                <td>                         
                    <input type="button" value="Send Invitation to Selected" onClick="doUnlink();"/>
                </td> 
            </tr> 
        </table>               
        </apex:form>  
    </apex:PageBlock>   

Now i want when anyone click the button.its retrive which checkboxs are selected. How can i do that Thanks in advance

  • 3
    What have you tried? Most people will not do something for you from scratch (most of us get paid to do that) but we'll be happy to help correct any mistakes you might've made p. – Sebastian Kessel Jan 10 '16 at 18:43
  • actually ive no idea how i bind it with apex.So that's why i asked it @SebastianKessel – moin khan Jan 10 '16 at 18:47
  • 3
    I would suggest you start by searching the apex documentation for <apex:inputcheckbox> – Sebastian Kessel Jan 10 '16 at 18:49
  • Moin check this out salesforce.stackexchange.com/questions/104469/… – Ratan Paul Jan 11 '16 at 5:03
  • @Ratan if there is multiple number of check box then what should i do – moin khan Jan 12 '16 at 15:45
1

Basically Salesforce follows MVC pattern. you can do this by two ways :

1. Using Visualforce Components: Visualforce is kind of view engine. Visualforce have its own components like <apex:inputField>, <apex:inputCheckbox>, etc. you should use them instead of standard html components as you had used <input type="text" />. You can map your apex properties with this visualforce components. eg:

<apex:inputCheckbox value="{! visualforce_property_Name }" label="singlecheck" />

Using Javascript Remoting: you can also use standard html components. In that case you should use standard html form.

Sample Code:

<form name="myForm">
    <table style="width:100%"> 
        <tr> 
            <th>Name</th> 
            <th>Deal</th> 
            <th>Experience</th> 
            <th>Location</th> 
            <th>Schedule Meeting
                <br/>
                Select all <input type="checkbox" id="SomeId" value="allCheck"/>
            </th> 
        </tr> 
        <tr> 
            <td>Customer Name</td> 
            <td>Deal Info</td> 
            <td>5 years</td> 
            <td>London</td> 
            <td> 
                <input type="checkbox" id="SomeId2" value="singlecheck"/>
            </td> 
        </tr> 
        <tr> 
            <td>Customer Name</td> 
            <td>Deal Info</td> 
            <td>5 years</td> 
            <td>London</td> 
            <td> 
                <input type="checkbox" id="SomeId3" value="singlecheck"/> 
            </td> 
        </tr> 
        <tr> 
            <td>Customer Name</td> 
            <td>Deal Info</td> 
            <td>5 years</td> 
            <td>London</td> 
            <td> 
                <input type="checkbox" value="singlecheck"/>
            </td> 
        </tr> 
        <tr> 
            <td>&nbsp;</td> 
            <td>&nbsp;</td> 
            <td>&nbsp;</td> 
            <td>&nbsp;</td> 
            <td>                         
                <input type="button" value="Send Invitation to Selected" onClick="doUnlink();"/>
            </td> 
        </tr> 
    </table>             
</form>

for this use case you can use RemoteActions in apex. follow Javascript Remoting

means take all checkbox values through javascript/jQuery, then call remote action in apex and provide these values as parameters to remote action. (Remote action is kind of AJAX request in salesforce).

I hope this will help you. :)

| improve this answer | |
  • but in my case ive multiple number of checkbox and i need to perform a particular task for select checkboxs – moin khan Jan 12 '16 at 15:52

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.