Gossamer Forum
Home : Products : DBMan : Installation :

Autofill fields

Quote Reply
Autofill fields
Hi Guys,

I am struggling to autoset certain fields based on the userid. I want to preset basic data like Tel and Fax number based on the userid that is logged in for Add new records only.

Help please.

Thanks in advance
Greg




Quote Reply
Re: Autofill fields In reply to
Do you have these fields in your .pass file? As it has been mentioned MANY times, it is not best to add fields in the .pass file. You should consider creating a "contact" database and then "information" database.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Autofill fields In reply to
Actually no. All I want is to preset certain fields (like Tel, Fax, email address etc. based on the db_userid) at the time of add to speed things up and make it easier for the user. I have seen the mod to extract info from last entry, but I rather want specific data. I tried an elaborate if-then section at the start of the sub_add-form, but it my Perl experience is lacking and it always takes the last if statement block. I was hoping this had been done before. I can't seem to find anything on the forum. Any assistance will be appreciated.

Tks again
Greg
Quote Reply
Re: Autofill fields In reply to
Are these values pre-determined, like does everyone have the same phone, fax, etc.?

If so, then all you have to do is type in the default values for the fields in your .cfg file.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Autofill fields In reply to
No the field values are different for each db_userid. I could setup the variables in cfg file or the html.pl, but it's where do the if statements go and their syntax that I seem to have the problem with. The statements at the start of sub_add_form I have are as follows:

if ($db_userid = "joe") {
$rec{'Tel'} = "375 6230";
$rec{'Fax'} = "375 6450";
$rec{'Email'} = "joe\@server.com";
}
if ($db_userid = "george") {
$rec{'Tel') = "899-0128";
$rec{'Fax'} = "899-0151";
$rec{'Email'} = "george\@server.com";
}
else {
&html_add_failure
}

This seems to give george's values even when db_userid=joe.

tks
Greg
Quote Reply
Re: Autofill fields In reply to
Where you have
Code:
if ($db_userid = "joe") {

you are automatically setting $db_userid to "joe", then doing it again with $db_userid = "george". Try changing the first parts of your if statements to :

Code:
if ($db_userid eq "joe") {

This checks for equality (text) without assigning a value. To check for numeric equality use ==. Hope that helps.

KipT