Solved

Code for multiple select boxes in perl

Posted on 1998-02-17
3
278 Views
Last Modified: 2013-12-25
what is the section of code for obtaining the data from a multiple select box.  I can get it to display the first value, but I need it to show all of the values selected.  The script is in perl.
0
Comment
Question by:7thwave
3 Comments
 
LVL 5

Expert Comment

by:icd
ID: 1831999
You don't state the script or module you are using to obtain the cgi variables. It is likely however that the script has put the multi-part data into a single variable (such as $in{myvar}) and separated them by the '\0' character. If this is the case then you can separate them with the following code.

@params = split ("\0", $in{myvar});

If this is not the case then let me know what cgi library/module you are using.

0
 
LVL 84

Expert Comment

by:ozo
ID: 1832000
I'd recommend CGI.pm:

#!/usr/bin/perl
use CGI qw(:standard);
print header;
print start_html('A Simple Example'),
      h1('A Simple Example'),
      start_form,
      checkbox_group(-name=>'words',
                     -values=>['eenie','meenie','minie','moe'],
                     -defaults=>['eenie','minie']),
      p,
      submit,
      end_form,
      hr;

if( param() ){
    print
        "The keywords are: ",em(join(", ",param('words'))),
        hr;
}
print a({href=>'http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html'},'Go to the documentation');

0
 
LVL 2

Accepted Solution

by:
yyyannag earned 50 total points
ID: 1832001
Try this :


$input{'input name'} =~ s/\0/, /g;

Then use the Print<<"EOD" as usual.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now