Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Multicolumn Pulldown Menu

by rodry (Beadle)
on Sep 25, 2000 at 04:46 UTC ( #33879=perlquestion: print w/replies, xml ) Need Help??

rodry has asked for the wisdom of the Perl Monks concerning the following question:

I have the following scenario. There are two tables, they are related in by the foreign key displayed in italics.
Table 1</b
table1IDint
table1descvarchar(20)
Table 2</b
table2IDint
table2descvarchar(20)
table1fkint
As you may have noticed, Table 2 contains the foreign key to Table 1, which is an intenger value (for the Autoincrement field in table 1). table1desc is really the value that matters for the user. It is the value that the user sees and selects when I display the pull-down menu in HTML and populate it with the contents of Table 1.

So my problem is as follows. When I display the list of values to the user I am forced to do so by displaying the foreign key value next to the description value in pairs(table1desc). Then, when the user submits the form, a script splits the values pairs to extract the foreign key, which is an integer.

I would like to know if there is a way to hide this value from the user without having to alter the table structure to make the description value (table1desc) the primary key. This is all because I don't want the user to see the value of the primary key of Table 1.

Thanks...

Replies are listed 'Best First'.
Re: Multicolumn Pulldown Menu
by jptxs (Curate) on Sep 25, 2000 at 05:45 UTC

    If I understand what you are doing here (maybe you could post code, resultant HTML?), you could simply put the value you want in the VALUE portion fo the INPUT tag and simply display the one desired field in the drop down menu. like:

    <SELECT NAME="selectName"> <OPTION VALUE="table1fk">table1desc <OPTION VALUE="table1fk">table1desc <OPTION VALUE="table1fk">table1desc </SELECT>

    this way the user sees what you want them to and your script gets what it needs to. I guess the point is, it doesn't matter what you use as the OPTION text, it's the OPTION VALUE that gets submited when your form gets parsed. So put whatever you want in the VALUE, and just display the little you wan to display.

    The other way to read this is that you want to hide the value of table1id alltogether. If this is the case, you can put another column on table2 that is unique, use that as the OPTION VALUE and that would let you get the proper row and not show the value of table1id. You can just use a sequnce or somthing that would be unique and automatic (even have a trigger populate it - note I'm from the Oracle world, your terms may vary).

    hope that helps...

    -- I'm a solipsist, and so is everyone else. (think about it)

      Thanks jptx! I did not know about the Value attribute of the Option tag.

      Silly me :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://33879]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2020-11-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?