You need to sign in to do that
Don't have an account?
Mrithula
how to bring the text box value to radio button or checkbox
hi,
i have a requirement that , the field X data type is "text" that holds values.
but in my Visual Force page the values in X that has text datatype should be displayed in "radio button" or " check box". based on the picklist value.
pls help me to achieve this..
Thanks in advance.
Hi you can make a list of checkbox by using List of selectoption type
All Answers
Make sence ...
how it is Display in Radio button/ Check box..
Question is wrong..
Hi you can make a list of checkbox by using List of selectoption type
thanks,
it's working :)
but how can i get the check box values without hardcoding..?
you can put values into selectoption list through a loop. For example if you have a list of 10 Account you can do it as:
It will return a selectoption list of 10 items.
here is my code:
PAGE:
<apex:page controller="textcheckbox">
<apex:form >
<apex:pageblock>
<apex:actionRegion>
<apex:inputField value="{!a.Type__c}" label="Select type">
<apex:actionSupport event="onchange" reRender="check,radio"/>
</apex:inputField>
</apex:actionRegion>
<apex:outputPanel id="check">
<apex:outputPanel rendered="{!a.Type__c='Checkbox'}">
<apex:selectCheckboxes value="{!anslist}">
<apex:selectOptions value="{!items}"/>
</apex:selectCheckboxes>
</apex:outputPanel>
</apex:outputPanel>
<apex:outputPanel id="radio" >
<apex:outputpanel rendered="{!a.Type__c='Radiobutton'}">
<apex:selectRadio value="{!anslist}">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio>
</apex:outputPanel>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
CLASS:
public class textcheckbox{
public list<answer__c> anslist{get; set;}
public answer__c a{get; set;}
public textcheckbox()
{
anslist= (List<answer__c>)[select opt1__c,opt2__c,opt3__c from answer__c ];
a= new answer__c ();
}
public List <SelectOption> getitems()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('anslist','anslist.answer__c' ));
return options;
}
}
Hi,
you can make a picklist for opt1 fields as:
anslist= (List)[select opt1__c,opt2__c,opt3__c from answer__c ];
public List getitems()
{
List options = new List();
for(answer__c a:anslist){
options.add(new SelectOption(a.opt1,a.opt1));
}
return options;
}