SF: in Salesforce, use apex to implement a drop-down list

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.