Thanks JPD,
I removed my code above so we did not have duplicates in this thread that would confuse others. Your code with my variables helped a lot and works fine. However, I did notice on testing that category field printed twice. Once as a select field (as it should) and again as a plain box field (as it should not)
SO, I changed the "IF" to "elsif"
___________db.cgi__________
if ($db_select_fields_category eq $field) {$output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field_from_categories_db($field,$rec{$field}) . "</td></tr>"; }
## the below code had "if" so I changed to elsif...
elsif ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}) . "</td></tr>"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}) . "</td></tr>"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}) . "</td></tr>"; }
elsif ($db_form_len{$field} =~ /(\d+)x(\d+)/) {
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea name="$field" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">$output~; }
elsif ($db_form_len{$field} == -2) { $per_admin ? ($output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$field" value="$rec{$field}" maxlength="$db_lengths{$field}"></td></tr>~) :
($output = qq~<input type=hidden name="$field" value="$rec{$field}">$output~); }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$field" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>~; }
}
_____________________
On testing, for some reason "add" does not pass category (Category (Can not be left blank) I will have to see why that is not getting passed there. Still testing
UPDATE:..
(hehe... you did the same thing I did on my first code attempt). We have to pass the $name (or make it equal to $column like the original routine. I will have to look closer to see just what we should do
$output = qq|<SELECT NAME="$name"><OPTION>---|;
$name is ""
UPDATE:
Had to change/add these lines like they where in the original ...sub build_select_field_from_db
sub build_select_field_from_categories_db {
# --------------------------------------------------------
# Builds a SELECT field from the database.
_______________-change this....
my ($column, $value) = @_;
________________to this...___
my ($column, $value, $name) = @_;
$name | | ($name = $column);
_______________________
This works now
Do you know what the "| |" says in the code above? My testing shows the code is setting $name = $column... but not sure what the rest says..
Thanks
TimRyan
[This message has been edited by timryan (edited August 11, 1999).]