CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [SOLVED] How to populate listbox with array?

Print topic Send  topic

Author Message
jsherk

Posts: 34
Posted: 01/25/2009, 6:52 AM

I have a listbox on a Record form and I need to populate the listbox choices with an array that looks something like this:
$countries['US'] = 'United States';  
$countries['CA'] = 'Canada';  
$countries['MX'] = 'Mexico';

Reading the help docs, it appears that I might want to set the Listbox Data Source Type to Procedure, but when I click on the little dropdown arrow for this property, I only get Table/View, SQL, & List Of Values... there is no option for Procedure.

Is there something else I need to set first, or is there just another way I should be doing this?

Any help would be appreciated... thanks.
View profile  Send private message
datadoit
Posted: 01/25/2009, 8:13 AM

Start here:
http://docs.codecharge.com/studio40/html/ProgrammingTec...Values.html?toc


More detailed sample of populating your array from a data table here:
http://forums.codecharge.com/posts.php?post_id=102308
jsherk

Posts: 34
Posted: 01/25/2009, 9:18 AM

Thanks datadoit... that worked perfect!!

For the sake of anybody else reading this, here is my solution:

I have a Form named NewAccountData, and a Listbox in that form named ListBox11. I have a custom function that retrieves a list of countries from a file located elsewhere. I then set the Listbox Data Source Type Property to ListOfValues, and then add the following custom code in the BeforeShow Event of the Listbox:

$countries_full = get_list_of_countries();  
//The above custom function (get_list_of_countries) retrieves a  
// list of countries in the following format:  
//  $countries_full['US'] = 'United States'  
//  $countries_full['CA'] = 'Canada'  
//  $countries_full['MX'] = 'Mexico'  
$countries_list = array();  
foreach ($countries_full as $country_key => $country_option) {    
  $countries_list []= array($country_key, $country_option);    
}   
$NewAccountData->ListBox11->Values = $countries_list;

That's it!!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.