Solved

Populate Drop Down List with Values from CSV DB

Posted on 1998-10-28
4
454 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
copy-item script help 15 85
script to run a program on a windows share drive every 10 mins 2 38
Permission on folders 6 25
Powershell Split 18 29
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

730 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