You need to sign in to do that
Don't have an account?
Leena.dev
get the values of checkbox if only checked into another object
Hi all,on vf page,iam having 4 checkbox, as
[].a)salesforce
[].b)sap
[].c)oracle
[].d)siebel
[].e)ibm
[].f)cloud
when ever checkbox like a,f are checked , only a) and f) should go to my custom object as A,F ..so after i need to compare it with correct answer which is in other object as A,F,,HOW TO COMPARE IT?? Am not gud in wrapper class,can any one help me to move..
Hi Leena,
Please go through below link which contains the example and usage of Wrapper class :-
http://wiki.developerforce.com/page/Wrapper_Class
Hi thanx vinit, but i Already have that,its not making move as iam new in coding
Hi,
You can do this with the following code
Apex
public with sharing class applications {
String[] applications = new String[]{};
public String[] getcrmAppplications() {
return applications;
}
public void setcrmAppplications(String[] applications) {
this.applications = applications;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('A','a) salesforce'));
options.add(new SelectOption('B','b) sap'));
options.add(new SelectOption('C','c) oracle'));
options.add(new SelectOption('D','d) siebel'));
options.add(new SelectOption('E','e) ibm'));
options.add(new SelectOption('F','f) cloud'));
return options;
}
public PageReference saveOptions() {
String selectedField;
for (String field : getcrmAppplications()){
selectedField = selectedField == null ? field : +selectedField+','+field;
}
System.debug('Fields are '+selectedField);
// Output as A,B,C based on the selected fields
// i assume object and field Names
for (Test_Object__c ans : [SELECT correctAnswer__c FROM Test_Object__c LIMIT 5000]){
if (ans.correctAnswer__c == selectedField){
// Your logic here
}
}
return null;
}
}
Visualforce
<apex:page controller="applications" >
<apex:form >
<apex:selectCheckboxes value="{!crmAppplications}" title="Choose">
<apex:selectOptions value="{!items}"/>
</apex:selectCheckboxes><br/>
<apex:commandButton value="Save" action="{!saveOptions}" />
</apex:form>
</apex:page>
Thanks a lot ,,,but was not getting.
if suppose user selected checkbox A& F(choosed checkbox) which iam storing it in a custom object(choosed option__c) now i need to compare it with correct answer__c object as A;F(correct answers).if both matches need to count .how i need to this? how to give result (marks)as pdf with all questions and answers????
Thanx in advance for your kind help..!!!