Apexpage:
<Apex: selectlist value = "{! Optionacc} "size =" 1 "style =" width: 230px ">
<Apex: selectoptions value = "{! Optionacclist} "> </Apex: selectoptions>
<Apex: actionsupport event = "onchange" Action = "{! Searchaccopplist} "rerender =" oppid/>
</Apex: selectlist>
Controller:
Public with sharing class accoppcontentcontroller {
Public String optionacc {Get; set ;}
Public list <selectoption> optionacclist {Get; set ;}
Private list <account> acclist = new list <account> ();
Public accoppcontentcontroller (){
Acclist = [select ID, name
From account order by name limit 10];
Optionacclist = new list <selectoption> ();
If (acclist! = NULL &&! Acclist. isempty ()){
Optionacclist. Add (New selectoption ('', '-- none --'));
For (account ACC: acclist ){
Optionacclist. Add (New selectoption (Acc. ID, ACC. Name ));
}
}
}
}
Drop-down list:
The value in <Apex: selectlist> is bound to a variable of the string type.
The value in <Apex: actionsupport> is bound to a list.
<Apex: actionsupport> bind an event to the control on it and a method.