Looping through a choice list

Not applicable

I have a table called "Project Codes" which is connected to my change form as a choice list.
Project codes have a number and a company name ... what I would like to do is prune
all project codes that do not belong to a certain company after the company field has been
filled.

What I'm not sure about is how to loop through a choice list ... any pointers? 🙂



function onChange(control, oldValue, newValue, isLoading) {
var requester = g_form.getReference('requested_by');
if (requester.company) {
var temp_pc_list = g_form.getReference('u_project_code');
g_form.getControl('u_project_code').options.length = 0;

// loop through temp_pc_list and add matching companies to u_project_code
// while (not end of list(temp_pc_list)) {
// if (list.element.company == requester.company) {
// g_form.addOption('u_project_code', '0', list.element);
// }
//}
}else{
/*No Company ... We don't do anything */
}

}

2 REPLIES 2

SharpAl
Kilo Contributor

Here's the loop:



var options = g_form.getControl('field_name').options;
for (i=0; i<options.length; i++) {
alert(options<i>.value);
}


Not applicable

cool thx!