Solved

Code for multiple select boxes in perl

Posted on 1998-02-17
3
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
convert Systemjs to Webpack 3 127
PowerShell and cisco ios 3 69
Powershell Split 18 43
Select String - If Else Statement - Powershell 8 46
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 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