format the multiselect option froma web form

V

Vit

Hi All,

I have a .cgi that read the value from a "multiselect option list" and
I get the following results:

$VAR1 = '1-option1';
$VAR2 = '3-option3';
$VAR3 = '5-option5';

is it possible to change the $VAR1, $VAR2 etc. etc. with something
customizable???

is it possible to format like this:

option1: selected
option2: not selected
option3: selected
option4: not selected
option5: selected
option6: not selected



the perl code is the following:

my @interest = $query->param("interest");

any suggestion?????

thanks all

Vit
 
T

Tad J McClellan

Vit said:
I have a .cgi that read the value from a "multiselect option list" and


Where your data comes from is not relevant to your question,
so it should not be included in your question.

Have you seen the Posting Guidelines that are posted here frequently?

I get the following results:

$VAR1 = '1-option1';
$VAR2 = '3-option3';
$VAR3 = '5-option5';


Where is your code that makes that output?

You should try to make a short and complete program *that we can run*
that illustrates your problem.

is it possible to format like this:

option1: selected
option2: not selected
option3: selected
option4: not selected
option5: selected
option6: not selected



the perl code is the following:

my @interest = $query->param("interest");


That code does not make any output at all, let alone the output
that you claim...

any suggestion?????

It is a SMOP.

Note that my answer makes no mention of the CGI environment, because
where the data comes from does not matter to the solution.

------------------
#!/usr/bin/perl
use warnings;
use strict;

my @interest = qw/ 1-option1 3-option3 5-option5 /;

my %selected;
foreach my $opt ( 'option1' .. 'option6' ) {
if( grep /$opt/, @interest ) {
$selected{$opt} = 'selected';
}
else {
$selected{$opt} = 'not selected';
}
}

print "$_: $selected{$_}\n" for sort keys %selected;
 
V

Vit

Where your data comes from is not relevant to your question,
so it should not be included in your question.

Have you seen the Posting Guidelines that are posted here frequently?



Where is your code that makes that output?

You should try to make a short and complete program *that we can run*
that illustrates your problem.





That code does not make any output at all, let alone the output
that you claim...


It is a SMOP.

Note that my answer makes no mention of the CGI environment, because
where the data comes from does not matter to the solution.

------------------
#!/usr/bin/perl
use warnings;
use strict;

my @interest = qw/ 1-option1 3-option3 5-option5 /;

my %selected;
foreach my $opt ( 'option1' .. 'option6' ) {
    if( grep /$opt/, @interest ) {
        $selected{$opt} = 'selected';
    }
    else {
        $selected{$opt} = 'not selected';
    }

}

print "$_: $selected{$_}\n" for sort keys %selected;

sorry for that...

I'm just reading a multiselection and put it on a "better format"....

use CGI;
use Data::Dumper;
use strict;
use warnings;

# Create the CGI object
my $query = new CGI;


my @interest = $query->param("interest"); (an array with the result
of the multiselection)

print MAIL Dumper @interest; (generate the text of en email)

and the result of in the email is as following:

$VAR1 = '1-option1';
$VAR2 = '3-option3';
$VAR3 = '5-option5';

what I'd like to "format" is the text of the email...

how can I generata an email with the text as following:

option1: selected
option2: not selected
option3: selected
option4: not selected
option5: selected
option6: not selected


thanks all


Vit
 
P

Peter J. Holzer

print MAIL Dumper @interest; (generate the text of en email)

Read the documentation of Data::Dumper and play around with the Dumper
function to understand what it does.

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top