Monks,
I've come to ask for help to something i thought i could do pretty easily but writing it out, i couldn't figure it out.
I'm trying to write a cgi script that will query a database table for a list, then display them as a dropdown box, which i've done before, but now i want to take the value from box A and use it to query the table again, displaying items that match the entry in box A.

Example:
Drop-down box A will have a list of pools (group of machines) once a pool is selected, i want to use that value to query the database and display hostnames associated with that pool in Drop down box B.

After that, i will have some static drop downs that will be ready for submit since i want to take all the values and do something with them.
I've seen tons of web forms where once i select something in the first drop down box, a second appears with info for me to select. I can't seem to come up with a flow/logic on how i can do that without adding some sort of javascript. Can anyone shed light on this?
I would greatly appreciate it.
Thanks,
PJ45

Here's what my code looks like now; its pretty incomplete, but it querys the database table to get information to create the values for the first dropdown.
i've changed some information on this post from what's in my script just to be safe, i.e. db name, table name, password, rules, vips etc.

sorry if that sounds like a dumb request. I just feel stuck without any guidance. Any help would be greatly appreciated.
Thanks again.
#!/usr/local/bin/perl -w ################ # Ray Espinoza # version: 0.1 # 6/29/04 ################# use strict; use DBI; use CGI qw(:standard); my ($pool, $host, $vip, $rule); ############## # Start HTML # ############## print header (), start_html (-title => "Rule Change Tool", -bgcolor => "#6666CC +", -text => "black"), h2("Rule Change Tool"); ######################## # grab database handle # ######################## my $dbh = &connect; ############## # main logic # ############## my $view = lc (param("view")); if($view eq "") { show_pools($dbh); } ######## # SUBS # ######## ################ sub show_pools { ################ my $dbh = shift; my $value = "pool"; my $poollist_ref = get_lookup_values($dbh, $value); print strong ("Resonate Rule Entry Form"), start_form (-action => url ()), table ( Tr ( td ("Pool: "), td (popup_menu (-name => "pool", -values =>$poollist_ref)) ), Tr ( td ("Hosts: "), br (), td (popup_menu (-name => "hosts", -values => [""])) ), Tr ( td ("VIP: "), td (popup_menu (-name => "vip", -values => ["", "home", "www"], -default => [""], -override => 1)) ), Tr ( td ("Rule: "), td (popup_menu (-name => "rule", -values => ["", "test", "test1", "test2", "test3"], -default => [""], -override => 1)) ), ), br (), submit (-name => "choice", -value => "Submit"), end_form (); } ####################### sub get_lookup_values { ####################### my ($dbh, $query) = @_; my ($sth, @val, $label_ref); $sth = $dbh->prepare(qq{ SELECT DISTINCT $query from table ORD +ER by $query }); $sth->execute (); # check whether or not query returns a label column $label_ref = {} if $sth->{NUM_OF_FIELDS} > 1; while (my @row = $sth->fetchrow_array ()) { push (@val, $row[0]); $label_ref->{$row[0]} = $row[1] if $label_ref; # add +label map entry } $sth->finish (); return (wantarray () ? (\@val, $label_ref) : \@val); } ############# sub connect { ############# use DBI; my ($dbh, $sth, $count); $dbh= DBI->connect("DBI:mysql:host=localhost;database=database","datab +aseuser","databasepassword",{PrintError => 0, RaiseError => 1}); return $dbh; }

In reply to Ideas for Logic to fill out this form by PerlJunkie45

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.