Solved

Populate Drop Down List with Values from CSV DB

Posted on 1998-10-28
4
459 Views
Last Modified: 2013-12-25
I'm using Front Page 98 to create a webpage.  I need a Drop Down List to be populated with values from a .CSV database.  I use Perl 5 to write CGI scripts sucessfully on other pages on this same site.  Anyone know how to do this?
0
Comment
Question by:EvanL
[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
  • 2
  • 2
4 Comments
 

Accepted Solution

by:
sax earned 110 total points
ID: 1829320
hi evan

You could load the data from the .CSV file into an associative array using perl and then populate the <select> statement from the arrays.

Following is an example:

;here is how to load the data into the arrays

 while (<DATA>) {
                ($userid,$username,$pword,$supplier,$email) = split(/,/);
                $suppl{$supplier} =  $username;
        }
        close DATA;      

;display the data as a drop down list

print "<tr><td>Select the Supplier:";
print "<td><select name=\"supplier\">";
while (($key, $value) = each %suppl) {
        print "<option value=$key>$value";
        print "\n";
    }
print "</select></table>";        

%suppl is the assoc array that holds the key and the values for the drop down list.

-HTH
sax
0
 
LVL 1

Author Comment

by:EvanL
ID: 1829321
I'm new to Perl 5 so lemme be specific so the code you post can reflect it.  The field name is "Last Name" in the .csv database and there are about 300 records there - each with a "Last Name" field filled.  So the drop down list would have to be filled with each record from the database.

I've increased the points so you will repost.. Thanks!
0
 
LVL 1

Author Comment

by:EvanL
ID: 1829322
Doh!  Also, what code appears in the .cgi file and which goes in the .html file?
0
 

Expert Comment

by:sax
ID: 1829323
I am assuming that each line in the file has one last name listed, as shown below:

SMith
Patrick

etc..

and you have enough knowledge of HTML that is being shown here.
============
The entire HTML file will have to generated by the perl script
===========
$inputdata = "csvfile";
open(DATA, $inputdata);

while (<DATA>) {
                    ($lastname) = split();
                    push $suppl, $lastname;
            }

;display the data as a drop down list
 ;print table

    print "<table>";
    print "<tr><td>Select the last name";
    print "<td><select name=\"lastname\">";
    foreach $element ($suppl) {
            print "<option value=$element>$element";
            print "\n";
        }
    print "</select></table>";          
       

-sax
                   
0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
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…

729 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