Gossamer Forum
Home : Products : DBMan : Customization :

Build_Fancy_Mult_Field (Possible??)

Quote Reply
Build_Fancy_Mult_Field (Possible??)
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:

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?

Smile

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).]
Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
I don't see any problem with your code.

I would look at the preview subroutine to make sure you have a Category field listed. Are you using hidden fields in your preview subroutine? If so, you might have just forgotten to add a Category field.


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





Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
Thanks for your quick response, Carol. Smile

I do not have any hidden fields other than db and uid in the Preview Form.

I am inserting two different types of the html_record_form...one for registered users and one for administrator.

Here is what I have in the sub html_preview_form routine:

Code:
|;
&html_submit_record(%in);
print qq|
<p>
<form action="$db_script_url" method="POST" name="form1" onSubmit="return formCheck()">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<hr noshade size="2" width="80%">
<INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Submit Job Posting!">  
<INPUT TYPE="SUBMIT" name="logoff" VALUE="Log Off">
<hr noshade size="2" width="80%">
</center>
<P>
|;
if ($per_admin) {
&html_admin_record_form(%in);
}
else {
&html_record_form(%in);
}
print qq|
<p><center>
<INPUT TYPE="SUBMIT" NAME="preview_record" VALUE="Edit Job Posting">
<INPUT TYPE="RESET" VALUE="Reset Form"></center></p></form>
|;

Anything I need to change here??

Thanks.

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).]
Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
I'm not sure. I might know better if I saw the source code for your preview routine. Any way I can try it out?



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





Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
Carol,

I will send you information about how you can access this database, okay?

You should be receiving an email message soon.

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: Build_Fancy_Mult_Field (Possible??) In reply to
I see what the problem is now.

I'll have to work on it to figure out how to fix it, though. It's not something I can come up with off the top of my head.


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





Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
No problem...Take your time...The car gods are not with me this week, so I may be stuck in Flagstaff. Frown

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: Build_Fancy_Mult_Field (Possible??) In reply to
This may be a little easier than I thought.

Try changing

Code:
$selector{$field}[$i][0] eq $compare ?

to

Code:
$compare =~/$selector{$field}[$i][0]/ ?

(I'll bow towards Detroit to see if I can get the car gods on your side. Smile )


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





Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
Carol,

It works! Thank you so much...Now I am going to test it with the search form.

Smile

Thanks for the thought with the car gods...still no answer from the repair shop...very bad karma!

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: Build_Fancy_Mult_Field (Possible??) In reply to
Okay...it is working great and with the new category listing mod...my Classified Ads are coming along very nicely.

However, I noticed a glitch associated with this mod (build fancy multiple select fields) (as well as the Category Modification). When I click on a category link, the record shows up fine, but I have hyperlinks in the short view that go to Category listings associated with records.

To see this in action, go to:

anthrotech.com/cgibin/classifieds/index.cgi?db=opps&uid=default&vr=1&ID=*&Category=Academic&sb=1&so=descend

You will see a record that was added on 23-Aug-1999 that has one link to two categories:

Academic,
Archaeology

If you click on the link, you get a Search failed link because it is looking for category: Academic, Archaeology in the search string.

Is there a way to separate these links in the html_record (my short view sub-routine)?? I know it may be a bit complicated, but any suggestions are greatly appreciated.

Smile

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).]
Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
I really don't know, Eliot. I suppose you could make two links.

You would have to create an array from the values in the field and then go through each member of the array at a time, much like the section I just gave you to change in the multiple fancy select field.


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





Quote Reply
Re: Build_Fancy_Mult_Field (Possible??) In reply to
Ahha! Good suggestion. I have done way too much coding today to think of how to do this...I do have some ideas starting to form...but before I screw up my scripts by hacking away at them...I think I will wait 'til tomorrow or the next few days to work on this.

Thanks for the pointer! 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