Gossamer Forum
Home : Products : DBMan : Customization :

? about build_external_select_field mod

Quote Reply
? about build_external_select_field mod
I need to do 2 things to this mod...

See attached text file of what I downloaded.


1 -- How do I get it to show just the second field, without the " " and

2 -- How do I limit the output to a specific district. I've added a variable to the .cfg file

that is called $db_district_name but I need help adding that to this code!



In my html.pl I have only:

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_red>*Site:</FONT></TD>
<TD COLSPAN="3" VALIGN="TOP">&nbsp;|; print &build_external_select_field ("Site", "$rec{'Site'}"); print qq|</TD></TR>


Do I need to replace that with the following?

print qq|<SELECT NAME="Test">|;
open (DB, "<$db_file_name2") or &cgierr("unable to open $db_file_name2. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if (!(grep $_ eq $fields[0], @selectfields)) {
push (@categories, $fields[0]);
}
}
close DB;

foreach $category (@categories) {
print "<OPTION>$category";
}
print qq|</SELECT>|;


And if I do, how can I get this to show just the second field?

Thanks for the help!
Lynette
Hollister, Ca

Last edited by:

Alex: Aug 5, 2003, 3:56 PM
Quote Reply
Re: [ltillner] ? about build_external_select_field mod In reply to
I see you have been working on it.

I had this same idea a while back and developed (but not fully tested) the following described in the text file;

It is based on the build_select_from_other_db

and I call it

build_limited_select_from_other_db

If I understand your question, (I hope) it will work fine.

To anyone else, this is rather specific to the District/School setup, but could be changed.

Also by trial and error I accidently developed a
build_select_from_2_fields_of_other_db
Shocked
Quote Reply
Re: [joematt] ? about build_external_select_field mod In reply to
Thanks Joe! This appears to be just what I needed. I needed to add 2 } at the end of the build statement for my db.cgi not to error out. So the end of the file now looks like:

if ($value eq $field) { $output .= "<OPTION SELECTED>$field";

}
else { $output .= "<OPTION>$field"; }
}
}


I have one problem now, no errors that I can see, but the select box doesn't appear!

This is what's in my .pl file under html_fa_record_form:

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_red>*Site:</FONT></TD>
<TD COLSPAN="3" VALIGN="TOP">&nbsp;|; print &build_limited_select_field_from_other_db ("Site", $rec{'Site'},2,1); print qq|</TD></TR>


attached is the .pl and .cfg for the Fixed Asset DB along with the dslist.db I created and my db.cgi. I don't see what I've missed that the select box is not appearing!


Thanks for your help Joe! Cool
Lynette
Hollister, Ca

Last edited by:

ltillner: May 1, 2003, 11:17 AM
Quote Reply
Re: [ltillner] ? about build_external_select_field mod In reply to
Laugh I GOT IT! Thanks Joe. the problem was this code, left off at the end of the sub in the db.cgi.

}

$output.="</SELECT>";

return $output;

}

I figured out that the two curly brackets were missing (because I got an internal server error) but hadn't looked to see what CODE between those curly brackets might also be missing!

It works now! Thanks so much, this is exactly what I needed! now, I assume that I can expand the columns of the DB out and call any column value in the list based on any other column?????

That is so cool!

THANKS A BUNCH (until you're better paid!!!!) Shocked
Lynette
Hollister, Ca
Quote Reply
Re: [ltillner] ? about build_external_select_field mod In reply to
You are welcome. Sorry I missed and did not paste the whole thing.CrazyCrazyCrazy

Yes you could call any 2 columns. And you can call them from ANY flat file, that is to say the .db file for the select field is NOT dependent on a config file. Does that make sense?

Now what I want to do is modify it so that it reads the critera from the form as the form is filled in, like your javascript select forms.

Also for school districts in particular I thought it could determine district based on zip code or address, HUM?

and I learned how to grep and push, maybe they should pay me more?
Quote Reply
Re: [joematt] ? about build_external_select_field mod In reply to
"THEY" should definately pay you more!

That was my next idea too, How can I make all the possible criteria for anyone site in a flat file but the form would need to be limited to which site somehow first. I'm not sure perl can do that interactively?

I don't know much about using memory variables with Perl/cgi like I do in Fox programming!

If you can figure that out, you would be in my favorite people list forever!

Lynette
Lynette
Hollister, Ca
Quote Reply
Re: [ltillner] ? about build_external_select_field mod In reply to
Joe,

This is just a thought... If you define the variable as something default or generic in the .cfg file (maybe even just a '---') and then when you have a selection made in the first box (in my case that's the Site or School) can you submit that and update the form with a refresh? that would change the dependent list boxes to be based on the site selected?

I do this in VFP with an internal requery or refresh without the user needing to do anything, but it could just be a button on the html page?

That's the advantage of the java, it can do this interactively, I don't know that perl can without some sort of post action.

Lynette
Lynette
Hollister, Ca
Quote Reply
Re: [ltillner] ? about build_external_select_field mod In reply to
Quote:
That's the advantage of the java, it can do this interactively, I don't know that perl can without some sort of post action.

Just you wait, Perl on every PC, but they won't call it Perl. And really just needs to be a subset of Perl's most basic functions.

OK, I don't get paid to dream.

I just dream about getting paid.
Quote Reply
Re: [joematt] ? about build_external_select_field mod In reply to
Joe:

Could you share the complete code for your build_limited_select_from_other_db

and also share your:

build_select_from_2_fields_of_other_db

It would be great if you could write up the mods and post them here and in the resource center :)

Lois

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] ? about build_external_select_field mod In reply to
I will do my best to write them up for general use.

Sometime this week.