Gossamer Forum
Home : Products : DBMan : Customization :

Problems with Default Values

Quote Reply
Problems with Default Values
I have a problem with default values...I have a variable Employee Type set up with the following values:

Administrator
Faculty
Classified Staff
Professional Staff
Temporary Staff

(The variables are:

Administrator
Faculty
Classified_Staff
Professional_Staff
Temporary_Staff

(I am using the fancy_select_fields mod that JPDeni has graciously worked on.)

The problem is that when my data managers try to modify a record with *Staff in it, they have to re-select the Employee Type. For example, let's say there is a Classified Staff position, the data manager has to re-select the Employee Type field in order to properly submit it. The records with Administrator and Faculty maintain their default value and the data managers do NOT have to re-select the values.

I know that I could probably rename the variables to something else unique, but that is problematic in terms of classifying the positions. (More of a political and logistical issue than a technical issue.)

Is there any way to work around this problem?

TIA Smile


------------------
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: Problems with Default Values In reply to
JPDeni,

I may be confused here...I have two
build_select_field sub-routines...One in
the html.pl file (which are the codes that posted in this Topic) and in the default.cgi (index.cgi for me) file.

Do I need to delete the sub-routine in the html.pl and put the variables back into the default.cfg file in the %db_select_fields array??


Yes, the values and variables are all spelled correctly.

Here are the URLs for the files you've requested:

http://www.coco.cc.az.us/cgi-bin/jobline/defaultcfg.txt

http://www.coco.cc.az.us/cgi-bin/jobline/htmlpl.txt

http://www.coco.cc.az.us/cgi-bin/jobline/indexcgi.txt

TIA. Smile

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: Problems with Default Values In reply to
I would have to see your "fancy" select field to know what the problem is.

Actually, there's another way of going about this that is simpler.

Set up a regular select field with the underscores between the words.

Change sub build_select_field in db.cgi to:

Code:
sub build_select_field {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition. Parameters are the column to build
# and a default value (optional).

my ($column, $value) = @_;
my (@fields, $ouptut);

@fields = split (/\,/, $db_select_fields{$column});
if ($#fields == -1) {
$output = "error building select field:
no select fields specified in config for field '$column'!";
}
else {
$output = qq|<SELECT NAME="$column"><OPTION>---|;
foreach $field (@fields) {
$showfield = $field;
$showfield =~ s/_/ /g;
$field eq $value ?
($output .= "<OPTION SELECTED value="$field">$showfield\n") :
($output .= "<OPTION value="$field">$showfield");
}
$output .= "</SELECT>";
}
return $output;
}

In when you display the record, after

my (%rec) = @_;

add

Code:
foreach $column (@db_cols) {
$rec{$column} =~ s/_/ /g;
}

You may have go through your .db file and make sure you have underscores in the options.


------------------
JPD





Quote Reply
Re: Problems with Default Values In reply to
JPDeni,

Here are the fancy field build codes:

Code:
sub build_fancy_select_field {
# --------------------------------------------------------
#
# To call this subroutine from html_record_form, use the following syntax:
#
# print &build_fancy_select_field("FieldName",$rec{'FieldName'});
#
# Be sure to express the field name *exactly* as it is defined in your .cfg file.
#
my $field = $_[0];
my $compare = $_[1];
my %selector = (
'Employee_Type' => [
['---','Choose one of the following:'],
['Adminstrator','Administrator'],
['Classified_Staff','Classified Staff'],
['Faculty','Faculty'],
['Professional_Staff','Professional Staff'],
['Temporary_Staff','Temporary Staff']
],
'Location' => [
['---','Choose one of the following:'],
['Flagstaff Campus','Flagstaff Campus'],
['Grand Canyon','Grand Canyon'],
['Page Campus','Page Campus'],
['Williams','Williams']
],
);
$output = qq|<SELECT NAME="$field">\n|;
$i = 0;
while ( $selector{$field}[$i][0] ) {
$selector{$field}[$i][0] eq $compare ?
($output .= qq|<OPTION VALUE="$selector{$field}[$i][0]" SELECTED>$selector{$field}[$i][1]\n|) :
($output .= qq|<OPTION VALUE="$selector{$field}[$i][0]">$selector{$field}[$i][1]\n|);
++$i;
}
if ($i) { $output .= "</SELECT>"; }
else { $output = "Incorrect field definition"; }
return $output;

}

BTW: I did change the sub build_select_field
with codes you wrote above. (That does not seem to be the problem.) I just now added the second set of codes in the html.pl. Let's see if it works.....

NOPE...Does not work...Still have to re-select the Employee_Type field. Shucks!

I'll try your suggestion and see if it works.

Thanks! Smile

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

[This message has been edited by Eliot (edited July 07, 1999).]
Quote Reply
Re: Problems with Default Values In reply to
I guess I was unclear.

If you use what I gave you above, you would change

print &build_fancy_select_field

to

print &build_select_field

You can get rid of the "fancy" select field altogether.


------------------
JPD





Quote Reply
Re: Problems with Default Values In reply to
JPDeni,

Welp, I took out fancy and it still does not work...Shucks! It really is a minor glitch...but the data managers are sensitive about receiving error messages when trying to modify and add records.

Thanks for your assistance.

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: Problems with Default Values In reply to
I know that the second code I gave you works, because I've used it for a client myself.

Are you sure that all of your field names are spelled correctly?

If you'll let me know where I can see your files on the web, I'll take a look at them. I will need to see db.cgi, html.pl, the .cfg file and the .db file.


------------------
JPD





Quote Reply
Re: Problems with Default Values In reply to
 
Quote:
Do I need to delete the sub-routine in the html.pl and put the variables back into the default.cfg file in the %db_select_fields array??

Yes. And you need to replace sub build_select_field with the code I gave you above.

I didn't look at the files yet, because of what you said.


------------------
JPD





Quote Reply
Re: Problems with Default Values In reply to
JPDeni,

Welp, made the following edits:

1) Deleted build_select_field from the html.pl file.

2) Double checked the codes in the default.cgi file to make sure they were exactly the same as the ones you posted in this Topic.

3) Put the variables in the db_select_fields in the default.cfg.

Problem not resolved. I still have to re-select the Employee Type...Very Strange,
indeed. Unfortunately, I think the only answer is to set-up unique values, such as
Administrator, Classified, Faculty, Professional, and Temporary for the Employee Type field.

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

[This message has been edited by Eliot (edited July 07, 1999).]
Quote Reply
Re: Problems with Default Values In reply to
I know the problem.

You addeded

Code:
foreach $column (@db_cols) {
$rec{$column} =~ s/_/ /g;
}

to html_record_form. That code is only for the display subroutines -- html_record and html_record_long.

You'll probably also need to manually replace the values in your .db file.



------------------
JPD





Quote Reply
Re: Problems with Default Values In reply to
Carol,

It works like a charm! By deleting those codes in the modify sub-routines, it works like a charm.

Our hats off to ya!

Kudos!

TIA Smile

------------------
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: Problems with Default Values In reply to
Whew! Smile

Glad to be of service.

------------------
JPD