Can you perform an "add" to a pull down list if DBMan SQL? I'd like to chose a category for each entry that is put into the database, but if it's not there, I'd like to be able to simply type it in and add it.
Jul 25, 2000, 1:30 AM
Veteran (8669 posts)
Jul 25, 2000, 1:30 AM
Post #5 of 5
Views: 3017
I didn't find the thread Eliot pointed to by using his search terms, so I'll tell you what I did.
In sub html_record_form, I have:
<TR><TD align=right valign=top><$font>Category:</font></td>
<TD>|; print &build_select_field_from_db("Category",$rec{'Category'});
if ($per_admin) {
print qq|<BR><input type=text name="Category" size="20" maxlength="255">
<$font>Add a new category</font></td></tr>|;
}
print qq|
You'll also need to make a change in sub validate_record. Add the code in red below:
foreach $col (@db_cols) {
$in{$col} =~ s/^~~//;
$in{$col} =~ s/~~$//;
if ($in{$col} =~ /^\s*$/) { # entry is null or only whitespace
if ($db_not_null{$col}) { # entry is not allowed to be null.
push(@input_err, "$col (Can't be Blank)"); # so let's add it as an error
}
}
If you don't add those lines, you'll end up with a ~~ at either the beginning or end of your field entry.
JPD
http://www.jpdeni.com/dbman/
In sub html_record_form, I have:
Code:
<TR><TD align=right valign=top><$font>Category:</font></td>
<TD>|; print &build_select_field_from_db("Category",$rec{'Category'});
if ($per_admin) {
print qq|<BR><input type=text name="Category" size="20" maxlength="255">
<$font>Add a new category</font></td></tr>|;
}
print qq|
Code:
foreach $col (@db_cols) {
$in{$col} =~ s/^~~//;
$in{$col} =~ s/~~$//;
if ($in{$col} =~ /^\s*$/) { # entry is null or only whitespace
if ($db_not_null{$col}) { # entry is not allowed to be null.
push(@input_err, "$col (Can't be Blank)"); # so let's add it as an error
}
}
JPD
http://www.jpdeni.com/dbman/