Gossamer Forum
Home : Products : DBMan : Customization :

Do multi upload and multi select work together?

Quote Reply
Do multi upload and multi select work together?
I've asked this question before and it wasn't answered. I thought I would try again. Does anyone have the multi select mod and the multi upload mod working together in a single database? I had multiselect working and when I put in multi upload the multi select stopped putting more than the first selection from the list into the database output. I'm using the short/long mod also.

Other posters had similar problems last year. tbaucom - are you out there and did you get it working?

Thanks,
Chris Whatley

Quote Reply
Re: Do multi upload and multi select work together? In reply to
When you installed the multi-select field mod you most likely added:

In db.cgi, sub parse_form:

after

if ($value eq "---") { next PAIR; }

add

unless ($value) { next PAIR; }

When you installed the multiple upload mod you replaced this sub and most likely did not check to see what was different and keep the changes for the multi-select mod.

It's always good to note within the script the changes you make so this doesn't happen when you add or replace subs, such as putting:

unless ($value) { next PAIR; } ### add for multi-select mod

Hope this solves your problem Smile

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Do multi upload and multi select work together? In reply to
Hi LoisC and others,

Thanks for the reply. Unfortunately, the problem is still not resolved even after adding the line to the sub parse routine. If you would take a look at my files I would be grateful. I have to do this same multi upload and multi select combination for several databases so I must get it working.

Here are the links to my files:

db.cgi: http://agecon.tamu.edu/dbcgi.txt
graduate.pl: http://agecon.tamu.edu/graduatepl.txt
graduate.cfg: http://agecon.tamu.edu/graduatecfg.txt

Please, Please, Please help!
Thanks for the help.
Chris Whatley

Quote Reply
Re: Do multi upload and multi select work together? In reply to
Still no help. Does anybody have multi-upload and multi-select working together? If so, will you either tell me what you did or post your code? I'm using the Multiple File Upload MOD at http://www.jpdeni.com/...ods/file-upload3.txt.

It appears that several routines were written over time to upload multiple files and they all have this problem when working with multi-select.

Somebody must have this working successfully and can help.

Thanks,
Chris Whatley

Quote Reply
Re: Do multi upload and multi select work together? In reply to
I haven't gotten this to work yet either.

I've been playing around with different things for a few days with no results yet.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Do multi upload and multi select work together? In reply to
Thank you for trying. I hope one of us reaches a solution to this problem soon. I'll keep you posted if I find anything that works and I hope you do the same.

Chris Whatley

Quote Reply
Re: Do multi upload and multi select work together? In reply to
I asked JPDeni if this was possible and her reply was that she didn't know how to make the two work together :(

I think i'm going to switch that filed to using several checkboxes, to get my current project completed.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Do multi upload and multi select work together? In reply to
I just can't believe that the two mods won't work together. Is it just the sub_parse routine? I wish I knew more about Perl. Please keep trying.

Thanks,
Chris Whatley

Quote Reply
Solution! (Work Around) In reply to
Well since both cwhatley and myself had the same problem, and no one was able to come up with a solution... I came up with a workaround :)

Rather than having the multi select box create a multi select box, I made it create a drop down list. Then I wrote a javascript that would allow me to select something from the list, and add it to a textarea, and it works for multiple entries IN CONJUCTION with the file upload mod!.

Check it out:
Edit your db.cgi, I changed the name of the subroutine to build_limited_multiple_select_field_from_other_db, I would suggest doing this to make things easier to distinguish, then change the subroutine where it outputs, to the following:
Code:
$output = qq|<SELECT NAME="s1"><OPTION>-None-|;
foreach $field (sort @selectfields) {
$selected = 0;
foreach $value (@values) {
if ($value eq $field) {
$output .= "<OPTION SELECTED>$field";
$selected = 1;
}
}
unless ($selected) {
$output .= "<OPTION>$field";
}
}
$output .= "</SELECT>";
return $output;
}
In the html_add_form of your html.pl add the following javascript somewhere between the <head> and </head> *REMEMBER TO CHANGE FIELDNAME*:
<SCRIPT LANGUAGE="JavaScript">
function additive(f,s,t,n) {
document.forms['javaform'].elements['FieldName'].value += document.forms['javaform'].elements['s1'].options[document.forms['javaform'].elements['s1'].selectedIndex].text + "\\n";
}
</SCRIPT>

In the same html.pl just below the head you should see the form statement, change it to this:
Code:
<FORM action="$db_script_url" method="POST" ENCTYPE="multipart/form-data" NAME="javaform">
insert this in your html_record_form of your html.pl, wherever you want it to appear (change "FieldName" to the name of the field you will be adding to):
Code:
|; print &build_limited_multiple_select_field_from_other_db("FieldName",$rec{'FieldName'});
print qq|<INPUT TYPE="button" VALUE="Add" ONCLICK="additive(1,1,1,1)"><BR>
<TEXTAREA NAME="FieldName" COLS="50" ROWS="10">$rec{'FieldName'}</TEXTAREA>
One last thing, make sure you have your FieldName defined properly in the default.cfg, should be something like this:
Code:
FieldName => [1, 'alpha', '40x3', 1000, 0, '', ''],
Now log back into your DB (hopefully no errors :) and try to add something... make sure theres some entries in the database you are pulling from to generate the drop down menu! Let me know how it goes, it works for me.

Majid Manzarpour
Digital Syncronos

Quote Reply
Re: Solution! (Work Around) In reply to
Can you inform me of necessary changes when I'm building the list from the .cfg file. Specifically, the

%db_select_fields = (DegreesReceived => 'AGBU,AGEC,MS,MAB,MBA,PhD,JD');

variable would still be used to generate the list.

Please let me know. It sounds just like what I'm looking for to solve my problems.

Thanks,
Chris Whatley

Quote Reply
Re: Solution! (Work Around) In reply to
Find the sub build_select_field sub routine in db.cgi, and change the line:
Code:
$output = qq|<SELECT NAME="$column"><OPTION>---|;
to read
$output = qq|<SELECT NAME="s1"><OPTION>---|;
Then change where you want your list to appear from my tutorial:
Code:
change:
|; print &build_limited_multiple_select_field_from_other_db("FieldName",$rec{'FieldName'}); print qq|
to this:
|; print &build_select_field ("Category", "$rec{'Category'}"); print qq|
Double check you followed my previous instructions, then make these changes.. hopefully it will work out!

Quote Reply
Re: Solution! (Work Around) In reply to
I'm almost there. I have the drop down box generated, but when I select from the list and hit the ADD button I get a javascript error. It says document.forms.javaform.elements.s1 has no properties.

Let me tell you what I've done. I have the javascript code showing in <head> codes of the page where the script is used, I have
<TR><TD ALIGN="Right" VALIGN="center"><$font>Degrees Received:*
<font size=-2>(Control key for multiple)</font></FONT></TD>
<TD VALIGN="center" colspan="2" > |; print &build_select_field ("DegreesReceived", "$rec{'DegreesReceived'}");
print qq|<INPUT TYPE="button" VALUE="Add" ONCLICK="additive(1,1,1,1)"><BR>
<TEXTAREA NAME="DegreesReceived" COLS="38" ROWS="2">$rec{'DegreesReceived'}</TEXTAREA></TD></TR>

showing in record_edit.

Here is my build routine:

sub build_select_field {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $size) = @_;
my (%values,@fields,$field);

$name || ($name = $column);

@fields = split (/\,/, $db_select_fields{$name});

($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

if ($size) {
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
$values{$value}++;
}

if ($size) {
# $output = qq|<SELECT NAME="$column" MULTIPLE SIZE=$size><OPTION>---|;

$output = qq|<SELECT NAME="s1"><OPTION>-None-|; # these lines were put in for multi-select and multi-upload
foreach $field (sort @selectfields) {
$selected = 0;
foreach $value (@values) {
if ($value eq $field) {
$output .= "<OPTION SELECTED>$field";
$selected = 1;
}
}
unless ($selected) {
$output .= "<OPTION>$field";
}
}
$output .= "</SELECT>";
return $output;
}

# start of regular routine

#}
# else {
# $output = qq|<SELECT NAME="$column"><OPTION>---|;
#}
# foreach $field (@fields) {
# $values{$field} ?
# ($output .= "<OPTION SELECTED>$field\n") :
# ($output .= "<OPTION>$field");
# }
# $output .= "</SELECT>";
# return $output;
}


I can't help but feel that I've messed up in the build routine. Can you help me out?

Thanks,
Chris


Quote Reply
Re: Solution! (Work Around) In reply to
 
Did you remember to change the field name like this?
<SCRIPT LANGUAGE="JavaScript">
function additive(f,s,t,n) {
document.forms['javaform'].elements['DegreesReceived'].value += document.forms['javaform'].elements['s1'].options[document.forms['javaform'].elements['s1'].selectedIndex].text + "\\n";
}
</SCRIPT>

And did you remember this part?
In the same html.pl just below the head you should see the form statement, change it to this:
<FORM action="$db_script_url" method="POST" ENCTYPE="multipart/form-data" NAME="javaform">

Double check those...



Quote Reply
Re: Solution! (Work Around) In reply to
Yes, I had changed those and am still getting the error..

Here is my add_form routine:

sub html_add_form {
# --------------------------------------------------------
# The add form page where the user fills out all the details
# on the new record he would like to add. You should use
# &html_record_form to print out the form as it makes
# updating much easier. Feel free to edit &get_defaults
# to change the default values.

$form_upload_add = 1;
$page_title = "Add a New Record";
&html_print_headers;

print qq|
<html><head><title>$html_title: $page_title</title>
<SCRIPT LANGUAGE="JavaScript">
function additive(f,s,t,n) {
document.forms['javaform'].elements['DegreesReceived'].value +=
document.forms['javaform'].elements['s1'].options[document.forms['javaform'].elements['s1'].selectedIndex].text
+ "\\n";
}
</SCRIPT>
</head>
<body bgcolor="#FFFFF7" text="#000000">
<center>|;


$submit_button = "Add Record";
# < -- Start page text -- >
print qq|

|;
# < -- End page text -->
print qq|
<FORM action="$db_script_url" method="POST" ENCTYPE="multipart/form-data" NAME="javaform">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
|;

&html_record_edit (&get_defaults);
print qq|
<p><center>
<INPUT TYPE="SUBMIT" NAME="add_record" VALUE="$submit_button">
</center></p></form>
|;
&html_footer;
&html_page_bottom;
}

Here is where I built the select list and put in the ADD button in Record_long: (THIS WORKS)

<TR><TD ALIGN="Right" VALIGN="center"><$font>Degrees Received:*
<font size=-2>(Control key for multiple)</font></FONT></TD>
<TD VALIGN="center" colspan="2" > |; print &build_select_field ("DegreesReceived", "$rec{'DegreesReceived'}");
print qq|<INPUT TYPE="button" VALUE="Add" ONCLICK="additive(1,1,1,1)"><BR>
<TEXTAREA NAME="DegreesReceived" COLS="38" ROWS="2">$rec{'DegreesReceived'}</TEXTAREA></TD></TR>

My build_select_field routine from db.cgi is listed in my previous post.

Here is my field in the .cfg file:

DegreesReceived => [13, 'alpha', '40x3', 1000, 0, '', ''],


I'm still getting the same error.

I really think I got confused in the build_select_field routine from db.cgi. I'm not positive I replaced the correct things. I'm confident I've done everything else correctly. I appreciate your help.

Thanks for your time - and infinite patience.

Chris Whatley



Quote Reply
Re: Solution! (Work Around) In reply to
Zip up your files and email them to me (majid@digisync.ca) I'll see what I can do.

Quote Reply
Re: Solution! (Work Around) In reply to
Thanks Majid,

The javascript now works. Here is a copy of the build_select_field routine:

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="s3"><OPTION>---|;
foreach $field (@fields) {
$field eq $value ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
}
return $output;
}



Follow the directions for putting in the Javascript code, changing the .cfg file, and placing the code in your record_edit routine in db.cgi and it should work now.

Thanks for all your efforts Majid. Works like a charm.

Chris Whatley