Program to create picklist field in VF page using arrays in Apex
Picklist using select option from apex:<apex: select list size=”1”>
<apex; select option item label =” Java” item value=” scup”/>
<apex: select option item label=” SF” item value =” SDFC”/>
<apex: select list>
In the apex program we can create same select option using an object select option.
Select option op1=new select option (item value, item label);
Public class select Example {
Public select option [] my options {set; get;}
Public select Example ()
{
Select option op3=new select option (‘null’ ‘-None’);
Select option op1= new select option (‘one’ ‘Jan’);
Select option op2= new select option (‘two’ ‘Feb’);
My option=new select option [] {op3, op1, op2};
}
}
<apex: page controller =” select Example”>
<apex: from>
<apex: select list size=”1”>
<apex: select option value=” {! my options}”> </apex: select option>
</apex: select list>
<apex: select list size=”1”>
<apex: select option item label =” Java” item value =” Java”> </apex: select option>
<apex: select option item label =” SFDC” item value =” SF”> </apex: select option>
</apex: select list>
</apex: from>
</apex: page>
No comments:
Post a Comment