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

I think what I want to do is simple, but I seem to be getting really confused.

I have a drop down menu in a Perl script. I want the drop down to display different information under it, based on what is selected in the drop down. This is my script:

use Win32::ODBC; use CGI qw(:standard); use CGI::Carp qw/fatalsToBrowser/; print "Content-Type:text/html\n"; print "\n"; print "<HTML>\n"; print "<HEAD>\n"; print "</HEAD>\n"; $cgi = new CGI; print start_form(-action=>$cgi->script_name()); print hidden(-name=>'Choice' -value=>$cgi->param('Select')); %labels = ("MA"=>"Mortgage Advisers", "CA"=>"Customer Advisers", "BM"= +>"Branch Management", "HO"=>"Head Office", "Acc"=>"Accord", "MSa"=>"M +CC Sales", "MSe"=>"MCC Service"); print popup_menu(-name=>'Select', -values=>[keys %labels], -default=>'', -labels=> \%labels); print submit(); print end_form(); print "Choice: $Config{'Choice'}\n";
Once I have the Choice value I want to use it to run a SQL query and print it out as part of the script (which is fine) but I when I select a Choice and hit 'Submit Query', the script just hangs. Why could that be?

Replies are listed 'Best First'.
Re: Drop down and display
by Anonymous Monk on Apr 13, 2006 at 14:08 UTC

    It's been a couple of hours now and no one has dared to answer you. It's mostly because your code is complete rubbish, style- and functionality-wise. I guess that is because you do not understand HTML forms and interaction of them and the server program via the CGI. As such, it doesn't do what you aim to do.

    Go read the synopsis of the CGI module first. Then come back and analyse this code (tested on command line only, not in web server environment):

      That's brilliant - it works. Now I just need to get it to query a SQL database using that value as part of the query.

      If I get stuck I'll ask another question - I need to get to grips with the CGI.pm before I do anything else!