I have a cgi script that consists of a drop down box that lists a number of servers (pulled from a db) and a number of fields that describe various properies of said servers.

At the moment I have manually set -value=>'unknown' for each field but I would like the default values of each of the fields to be populated with values pulled from a db table (keyed on the server name) the moment a user selects a particular server from the drop down box in the form.

Is there a way to do this other than resorting to javascript?

Here's a snipit of the code as it stands now:

my $hostname_ref = $dbh->selectcol_arrayref("SELECT hostname FROM perm +_inventory ORDER BY hostname"); print $q->header ( "text/html" ), $q->start_html ( -title=>'Modify Server in inventory', -author=> 'devnull@devnull.com', -BGCOLOR=>'orange', -style=>{'src'=>'/form.css'} ), $q->h1 ( "Modify servers into USG inventory" ), $q->hr, $q->start_form( -method => "get", -action => "inv" ), $q->p( "Hostname", $q->popup_menu( -name => "host", -values => $hostname_ +ref) ), $q->p("Vendor", $q->textfield( -name => "vendor", -size => "40", -maxl +ength => "80",-value => "unknown") ), $q->p( "Serial No", $q->textfield( -name => "sn", -size => "40", -maxlengt +h => "80", -value => "unknown") ), $q->p( "Physical Location", $q->textfield( -name => "phy_loc", -size => "40", -max +length => "80", -value => "unknown") ), $q->p( "Raid Config", $q->textfield( -name=>'raid_conf', -size => "40", -max +length => "100", -value => "unknown") ), $q->p( "Function", $q->textfield( -name => "function", -size => "40", -ma +xlength => "60", -value => "unknown") ), $q->p( "Backup Locations", $q->textfield( -name => "bkup_loc", -size => "40", -ma +xlength => "80", -value => "unknown") ), $q->p( "Recovery Media", $q->textfield( -name => "recov_loc", -size => "40", -m +axlength => "80", -value => "unknown") ), $q->submit( -value => "Send to INV cgi"), $q->end_form, $q->end_html;

In reply to cgi drop down boxes triggering form field population by dhj74

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.