Solved

Code for multiple select boxes in perl

Posted on 1998-02-17
3
284 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

624 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