randallmarquis has asked for the wisdom of the Perl Monks concerning the following question:
The select box output looks like this:<center> <table width=450 CELLPADDING=0 CELLSPACING=0 BORDER=0 BGCOLOR="#FFFFf +f"> <tr><td><img src="http://lender-reviews.com/img/logo.png"> <br> <P align=center><font face=Arial size=2>Pick which Company you wish +to modify: <P> <FORM ACTION="$db_script_url" METHOD="GET"> <P><center>|; print &build_select_field_from_db ("name", "record-nu +mber", "modify"); print qq|</center> <P><INPUT TYPE="HIDDEN" NAME="modify_form_record" VALUE="1"> <center><INPUT TYPE="SUBMIT" VALUE="Modify"> <INPUT TYPE="RESET" VA +LUE="Reset Form"></center> </FORM> $html_menu $html_footer </font> </td></tr> </table> </center>
<P> <FORM ACTION="http://lender-reviews.com/cgi/dbmod.cgi/lender/lynn909 +67.htm" METHOD="GET"> <P><center><SELECT NAME="modify"><OPTION>---<OPTION>1ST ALLIANCE LE +NDING, LLC<OPTION>1ST COMMONWEALTH BANK OF VIRGINIA<OPTION>1ST MARYLA +ND MORTGAGE CORPORATION<OPTION>A PLUS MORTGAGE SERVICES INC<OPTION>AC +CESS NATIONAL MORTGAGE CORPORATION<OPTION>ACHIEVA CREDIT UNION<OPTION +>ACOPIA LLC</SELECT><P><INPUT TYPE="HIDDEN" NAME="modify_form_record" + VALUE="1"> <br> <center><INPUT TYPE="SUBMIT" VALUE="Modify"> <INPUT TYPE="RESET" VA +LUE="Reset Form"></center><br> </FORM>
The routine that creates the content is "build_select_field_from_db"
Here is the routine in full:
And therein lies my problem. I need the select box content changed to include the value of the database key, which is the first column in the database (known as 'record-number')sub build_select_field_from_db { # -------------------------------------------------------- # Builds a SELECT field from the database. my ($column, $value, $name) = @_; my (@fields, $field, @selectfields, @lines, $line, $ouptut); my ($fieldnum, $found, $i) = 0; for ($i = 0; $i <= $#db_cols; $i++) { if ($column eq $db_cols[$i]) { $fieldnum = $i; $found = 1; last; } } if (!$found) { return "error building select field: no fields specified!"; } open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_na +me. Reason: $!"); @lines = <DB>; close DB; LINE: foreach $line (@lines) { if ($line =~ /^#/) { next LINE; } # Skip comment lines. + if ($line =~ /^\s*$/) { next LINE; } # Skip Blank Lines. chomp ($line); @fields = &split_decode ($line); if (!(grep $_ eq $fields[$fieldnum], @selectfields)) { push (@selectfields, $fields[$fieldnum]); } } if ($name) { $output = qq|<SELECT NAME="$name"|; } else { $output = qq|<SELECT NAME="$column"|; } $output .= "><OPTION>---"; foreach $field (sort @selectfields) { if ($field eq $value) { $output .= "<OPTION SELECTED>$field"; } else { $output .= "<OPTION>$field"; } } $output .= "</SELECT>"; return $output; }
This line: $output .= "<OPTION>$field"; Needs to be changed to this somehow: $output .= "<OPTION value=\"record-number\">$field";
Where the above 'record-number' actually pulls the data from that record.
Here's what a line out of the database looks like:
5111|ACOPIA LLC|BRANT PHILLIPS|306 NORTHCREEK BLVD STE
The actual desired outcome is to create a 'SELECT' tag that looks like this:
<OPTION value="5111">ACOPIA LLC
Simple? I don't know... I tried $db_key but it only returned the name of the field (record-number) and not the data.
Randall Marquis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help syntax?
by ikegami (Patriarch) on Jul 12, 2010 at 01:19 UTC | |
by randallmarquis (Initiate) on Jul 12, 2010 at 01:49 UTC | |
by ikegami (Patriarch) on Jul 12, 2010 at 02:05 UTC | |
by randallmarquis (Initiate) on Jul 12, 2010 at 03:14 UTC | |
by randallmarquis (Initiate) on Jul 12, 2010 at 03:27 UTC | |
| |
|
Re: Help syntax?
by kejohm (Hermit) on Jul 12, 2010 at 09:36 UTC |