Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Dynamic Pull Down

Quote Reply
Dynamic Pull Down
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.

Quote Reply
Re: Dynamic Pull Down In reply to
It could be possible....One suggestion is to add a field to your add forms, but not directly written to the tables you are using for DBMAN. Then have this information sent to you via email if you are using the Validation Mod.

Regards,

Eliot

Quote Reply
Re: Dynamic Pull Down In reply to
There's no need to email it to me, just update the list on demand. I'll make sure that only adminstrators get the "Add to list" field.

Quote Reply
Re: Dynamic Pull Down In reply to
Welp...JPDeni, the Moderator of the DBMAN forums, wrote this kind of Modification about a year ago...Try searching the DBMAN Customization Forum for adding drop down values JPDeni.

You will have to edit her modification to work with the MySQL table.

Regards,

Eliot

Quote Reply
Re: Dynamic Pull Down In reply to
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:

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">
&nbsp;&nbsp;<$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:

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
}
}
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/