i am using callserver to populate the drop down menus from the database. the callserver is working well and i am able to get the data and populate the drop down menus well.
here is the issue: after the editor creates a new dcr and saves it, the next time he/she opens it for editing only the values shows up and after the page is fully loaded the drop down menus get populated with a fresh drop down menu and the old values/label disappear.
now i added the code below which am passing a paramter called defaultOptionSelected through my fetchdata function that will do the callserver for me and testing it with the selected item , if an item has been selected then take the value of that item and replace it with its label. however when i run this code the the last item in my drop down menu shows up????
any clues where is the problem that i have in this code
my $in = new CGI;
my $defaultOptionSelected = $in->param('defaultOptionSelected');
.
.
.
my $arrayOptions ='';
my $i = 0;
while ( @data = $sth->fetchrow_array())
{
$labels = $data[1];
$values = $data[0];
if ($labels){
my $test = 1;
foreach my $value($values){
my $isDefaultSelected = ( ! $defaultOptionSelected && $test ) || $value eq $defaultOptionSelected ? "true" : "false";
$arrayOptions .= "first_ddm[" . $i++ . "] = new Option('$labels','$values', $isDefaultSelected, $isDefaultSelected );\n";
$test = undef;
}
}
}
and this is part of my formapi code that i guess needs a modification
function fetchdata(defaultOptionSelected ) {
// Call server code goes here.
var params = new Object();
params.defaultOptionSelected = defaultOptionSelected ;
params.content_type_id = "rdacontent_content_type_id";
params.default_display_template_id = "rdacontent_template_id_articlegametool";
alert ("test");
IWDatacapture.callServer("/iw-bin/db_to_callserver.ipl", params, true);
}
and this is a simple out put of the ipl
first_ddm[0] = new Option('Article','6', true, true );
first_ddm[1] = new Option('EUFOT Item','30', true, true );
first_ddm[2] = new Option('EUFOT Problem','29', true, true );
first_ddm[3] = new Option('EUFOT Specialty','32', true, true );
first_ddm[4] = new Option('Game','9', true, true );
first_ddm[5] = new Option('Greeting Card','24', true, true );
any help will be appreciated