Carol et al,
I am trying to modify the build_fancy_select_field mod that you wrote to include multiple selections.
First Question: Is this possible?
Here is what I have so far:
1) Created a new sub-routine called build_fancy_mult_field in html.pl file:
# --------------------------------------------------------
#
# To call this subroutine from html_record_form, use the following syntax:
#
# print &build_fancy_mult_field("FieldName",$rec{'FieldName'});
#
# Be sure to express the field name *exactly* as it is defined in your .cfg file.
#
$size = "5";
my $field = $_[0];
my $compare = $_[1];
my %selector = (
'Category' => [
['---','Choose as many that apply:'],
['Academic','Academic Position'],
['Applied','Applied Anthropology'],
['Archaeology','Archaeology'],
['Biological','Biological-Physical Anthropology'],
['Business','Business Anthropology'],
['Cultural','Cultural Anthropology'],
['CRM','Cultural Resource Management'],
['Design','Design Anthropology'],
['Development','Development Anthropology'],
['Environmental','Environmental Anthropology'],
['Internship','Internship'],
['Linguistic','Linguistic Anthropology'],
['Medical','Medical Anthropology'],
['Other','Other'],
['Paleontology','Paleontology'],
['Political','Political Anthropology'],
['Primatology','Primatology'],
['Psychological','Psychological Anthropology'],
['Visual','Visual Anthropology'],
],
);
$output = qq|<SELECT NAME="$field" MULTIPLE SIZE="$size">\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;
}
2) Added the following codes in my html_submit_record, html_record_long, and html_record sub-routines:
$rec{$column} =~ s/~~/, /g;
}
3) Added the following codes to my sub html_record_form:
Result:
When I submit an Ad to be Previewed (I have a preview sub-routine that allows submitters to view their records before "adding" them to the database), the categories show up. Yet, when I submit the Ad from the Preview Screen, I get an Unable to Add Record Error with Category (Can not be left blank).
This is what shows up in the source code from my web browser:
<OPTION VALUE="---">Choose as many that apply:
<OPTION VALUE="Academic">Academic Position
<OPTION VALUE="Applied">Applied Anthropology
<OPTION VALUE="Archaeology">Archaeology
<OPTION VALUE="Biological">Biological-Physical Anthropology
<OPTION VALUE="Business">Business Anthropology
<OPTION VALUE="Cultural">Cultural Anthropology
<OPTION VALUE="CRM">Cultural Resource Management
<OPTION VALUE="Design">Design Anthropology
<OPTION VALUE="Development">Development Anthropology
<OPTION VALUE="Environmental">Environmental Anthropology
<OPTION VALUE="Internship">Internship
<OPTION VALUE="Linguistic">Linguistic Anthropology
<OPTION VALUE="Medical">Medical Anthropology
<OPTION VALUE="Other">Other
<OPTION VALUE="Paleontology">Paleontology
<OPTION VALUE="Political">Political Anthropology
<OPTION VALUE="Primatology">Primatology
<OPTION VALUE="Psychological">Psychological Anthropology
<OPTION VALUE="Visual">Visual Anthropology
</SELECT>
I almost have this working.
Second Question: Can you see anything that I need to change in the codes I've provided?
TIA.
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 August 23, 1999).]
[This message has been edited by Eliot (edited August 23, 1999).]
I am trying to modify the build_fancy_select_field mod that you wrote to include multiple selections.
First Question: Is this possible?
Here is what I have so far:
1) Created a new sub-routine called build_fancy_mult_field in html.pl file:
Code:
sub build_fancy_mult_field { # --------------------------------------------------------
#
# To call this subroutine from html_record_form, use the following syntax:
#
# print &build_fancy_mult_field("FieldName",$rec{'FieldName'});
#
# Be sure to express the field name *exactly* as it is defined in your .cfg file.
#
$size = "5";
my $field = $_[0];
my $compare = $_[1];
my %selector = (
'Category' => [
['---','Choose as many that apply:'],
['Academic','Academic Position'],
['Applied','Applied Anthropology'],
['Archaeology','Archaeology'],
['Biological','Biological-Physical Anthropology'],
['Business','Business Anthropology'],
['Cultural','Cultural Anthropology'],
['CRM','Cultural Resource Management'],
['Design','Design Anthropology'],
['Development','Development Anthropology'],
['Environmental','Environmental Anthropology'],
['Internship','Internship'],
['Linguistic','Linguistic Anthropology'],
['Medical','Medical Anthropology'],
['Other','Other'],
['Paleontology','Paleontology'],
['Political','Political Anthropology'],
['Primatology','Primatology'],
['Psychological','Psychological Anthropology'],
['Visual','Visual Anthropology'],
],
);
$output = qq|<SELECT NAME="$field" MULTIPLE SIZE="$size">\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;
}
2) Added the following codes in my html_submit_record, html_record_long, and html_record sub-routines:
Code:
foreach $column (@db_cols) { $rec{$column} =~ s/~~/, /g;
}
3) Added the following codes to my sub html_record_form:
Code:
print &build_fancy_mult_field("Category",$rec{'Category'});Result:
When I submit an Ad to be Previewed (I have a preview sub-routine that allows submitters to view their records before "adding" them to the database), the categories show up. Yet, when I submit the Ad from the Preview Screen, I get an Unable to Add Record Error with Category (Can not be left blank).
This is what shows up in the source code from my web browser:
Code:
<SELECT NAME="Category" MULTIPLE SIZE="5"> <OPTION VALUE="---">Choose as many that apply:
<OPTION VALUE="Academic">Academic Position
<OPTION VALUE="Applied">Applied Anthropology
<OPTION VALUE="Archaeology">Archaeology
<OPTION VALUE="Biological">Biological-Physical Anthropology
<OPTION VALUE="Business">Business Anthropology
<OPTION VALUE="Cultural">Cultural Anthropology
<OPTION VALUE="CRM">Cultural Resource Management
<OPTION VALUE="Design">Design Anthropology
<OPTION VALUE="Development">Development Anthropology
<OPTION VALUE="Environmental">Environmental Anthropology
<OPTION VALUE="Internship">Internship
<OPTION VALUE="Linguistic">Linguistic Anthropology
<OPTION VALUE="Medical">Medical Anthropology
<OPTION VALUE="Other">Other
<OPTION VALUE="Paleontology">Paleontology
<OPTION VALUE="Political">Political Anthropology
<OPTION VALUE="Primatology">Primatology
<OPTION VALUE="Psychological">Psychological Anthropology
<OPTION VALUE="Visual">Visual Anthropology
</SELECT>
I almost have this working.
Second Question: Can you see anything that I need to change in the codes I've provided?
TIA.
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 August 23, 1999).]
[This message has been edited by Eliot (edited August 23, 1999).]