Solved

Dynamic pop up menus

Posted on 1998-07-13
4
167 Views
Last Modified: 2013-11-28
I want to display a popup menu on my form. The options of this popup ought to come from a DB table.

e.g there could be a table having employee codes and employee names. I would like to display all the names in the DB table as a popup menu on a form for the user to be able to select any one.

Effectively which would mean that if any record is deleted from the DB we don't see that entry as an option on the popup menu.

Could somebody give me a way to do this.
0
Comment
Question by:sanjaychopra
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1208401
Since you don't say what database you're using, or how you're getting the list of data from the database, it's a little difficult to be explicit, but you're looking for something along the lines of:


print "<SELECT NAME=\"Menu_Variable\">\n";
my(@datalist) = <source your data here>
foreach (@datalist) {
   print "<OPTION VALUE=\"$_\"> $_\n";
}
print "</Select>\n";



By the way, this isn't reallly a perl question, but rather an HTML question...
0
 

Author Comment

by:sanjaychopra
ID: 1208402
Thanks for your reply.

I think I need to elaborate upon the problem a bit more to get a more accurate answer from you.

I am using an Oracle Database.
I have a table with the following structure :

 Name                            Null?    Type
 ------------------------------- -------- ----
 ID                              NOT NULL CHAR(3)
 NAME                            NOT NULL VARCHAR2(30)
 AGE                                      NUMBER(38)
 SEX                                      CHAR(1)

Let us assume we have five records in this table.
Now I would like to have a pop up menu or a radio buttons
group listing all the ids that are there in the table.

I was approaching the problem by building an array which would have all the id's that there in the the table at the point of time and then trying to use this array with the the default method of showing popup menus in PERL.


      #print "<P><EM>Select an ID</EM><BR>";
        #$query->popup_menu(
        #                -name=>'id',
        #                -values=> [the name of the array that i am building]
        #                ),"<P>";
 
But somehow i am not able to do that.
Coule you help ne solving the problem by this approach.
0
 

Author Comment

by:sanjaychopra
ID: 1208403
Thanks for your reply.

I think I need to elaborate upon the problem a bit more to get a more accurate answer from you.

I am using an Oracle Database.
I have a table with the following structure :

 Name                            Null?    Type
 ------------------------------- -------- ----
 ID                              NOT NULL CHAR(3)
 NAME                            NOT NULL VARCHAR2(30)
 AGE                                      NUMBER(38)
 SEX                                      CHAR(1)

Let us assume we have five records in this table.
Now I would like to have a pop up menu or a radio buttons
group listing all the ids that are there in the table.

I was approaching the problem by building an array which would have all the id's that there in the the table at the point of time and then trying to use this array with the the default method of showing popup menus in PERL.


      #print "<P><EM>Select an ID</EM><BR>";
        #$query->popup_menu(
        #                -name=>'id',
        #                -values=> [the name of the array that i am building]
        #                ),"<P>";
 
But somehow i am not able to do that.
Coule you help ne solving the problem by this approach.
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1208404
I'm sorry, I just saw that this message was here.

Ummm, two steps:

1.) Assuming that the array of values loaded from the database is called @tArr, try using

   -values => [@tArr],

Yes, Actually put the square braces in there.

2.) If that doesn't help, send more code... (i.e. the select code and the popup_menu code.  Also, tell me what happens when it runs.

Hopefully, step 1 will work.

0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File Find regex problem 4 62
Need to make a quick brochure in the next one hour 3 132
Perl script to delete older files 6 86
Export Variables in Perl 3 68
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
A great marketing strategy is diverse.  Read about the not so popular, yet effective, marketing tactics you can start using today!
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

770 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