Sorry, my last message was wrong, I put that thinking about the checkbox
situation.
I think the following may be an answer:
sub set_multiselect_option {
my ($form, $option_name, $non_null_value, $select) = @_;
# $form is the HTML::Form object
# $optin_name is the name of the options of the select input
# $non_null_value is the value that caracterizes the option
# $select: positive value to select, 0 or undef to uncheck the option
my $target_input;
foreach my $input ($form->inputs) {
my @possible_values = $input->possible_values;
if ($input->name eq $option_name and "@possible_values" =~
$non_null_value) {
$target_input = $input;
last;
}
}
return unless $target_input;
if ($select) { $target_input->value($non_null_value); }
else { $target_input->value(undef); }
}