You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Anton Slabbinck <an...@westsite.be> on 2001/06/07 15:48:55 UTC

problem with multiple select

Hi,

I'm having problem to get the result of a <SELECT ... MULTIPLE> field in a
form.
something like this works file :
   <FORM name=FormName method=post>
     <SELECT name=aSelectField size=4 multiple>
         <OPTION value=one>first</OPTION>
         <OPTION value=two>second</OPTION>
         <OPTION value=three>third</OPTION>
       </SELECT>
   </FORM>
   <P>aSelectField2 : <%
     @selectFields = $Request->Params('aSelectField');
     print join ',', @selectFields
   %>
   </P>

But I also need to upload a file with this form.
When I add ENCTYPE="multipart/form-data" to the form tag,
I can only retrieve the first selected item from aSelectField.
It's like the wantarray doesn't work anymore.

Does anybody know how to fix this ?

Anton.

-----------------------------------------------------
- WestSite NV - I N T E R N E T  S O L U T I O N S  -
-----------------------------------------------------
Torhoutse Steenweg 337
8200 Brugge
BELGIUM
T.+32 50 39 41 41
F.+32 50 39 41 43
mailto:anton@westsite.be
-----------------------------------------------------
http://www.westsite.be
http://wap.westsite.be
-----------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: problem with multiple select

Posted by Anton Slabbinck <an...@westsite.be>.
Hi,

Thanks for the information, but it still doesn't work for me.
Can you test this on your server :

test1.html =
<FORM  action="test2.html" name=FormName method=post
ENCTYPE="multipart/form-data">
<SELECT name=aSelectField size=4 multiple>
<OPTION value=one>first</OPTION>
<OPTION value=two>second</OPTION>
<OPTION value=three>third</OPTION>
</SELECT>
<input type="submit" name="submit" value="submit">
</FORM>

test2.html =

<P>aSelectField2 : <%
@selectFields = $Request->Form('aSelectField');
print join ',', @selectFields
%>
</P>

Notice the enctype in the form, I need this for de file-upload to work.

Anton.

-----------------------------------------------------
- WestSite NV - I N T E R N E T  S O L U T I O N S  -
-----------------------------------------------------
Torhoutse Steenweg 337
8200 Brugge
BELGIUM
T.+32 50 39 41 41
F.+32 50 39 41 43
mailto:anton@westsite.be
-----------------------------------------------------
http://www.westsite.be
http://wap.westsite.be
-----------------------------------------------------


> From: "JC Fant IV" <jf...@hotmail.com>
> Date: Thu, 7 Jun 2001 09:36:35 -0700
> To: "Anton Slabbinck" <an...@westsite.be>, <as...@perl.apache.org>
> Subject: Re: problem with multiple select
> 
> you can do two different things..
> 
>> Hi,
>> 
>> I'm having problem to get the result of a <SELECT ... MULTIPLE> field in a
>> form.
>> something like this works file :
> 
> 
> 1.) change the form from method=post to method=get
> <FORM name=FormName method=get>
> 
> and the code should work. However if you want to upload a file you are going
> to need to use  the second example.
> 
>> <FORM name=FormName method=post>
>> <SELECT name=aSelectField size=4 multiple>
>> <OPTION value=one>first</OPTION>
>> <OPTION value=two>second</OPTION>
>> <OPTION value=three>third</OPTION>
>> </SELECT>
>> </FORM>
>> <P>aSelectField2 : <%
> 
> 2. to grab the incoming post information Use
> 
> $Request->Form('aSelectField');
> this will pull in the posting form.
> 
>> @selectFields = $Request->Params('aSelectField');
>> print join ',', @selectFields
>> %>
>> </P>
>> 
> 
> I tried this code on my server and works fine.
> 
> test1.html =
> <FORM  action="test2.html" name=FormName method=post>
> <SELECT name=aSelectField size=4 multiple>
> <OPTION value=one>first</OPTION>
> <OPTION value=two>second</OPTION>
> <OPTION value=three>third</OPTION>
> </SELECT>
> <input type="submit" name="submit" value="submit">
> </FORM>
> 
> test2.html =
> 
> <P>aSelectField2 : <%
> @selectFields = $Request->Form('aSelectField');
> print join ',', @selectFields
> %>
> </P>
> 
> 
> test2.html returned
> 
> aSelectField2 : one,two,three
> #########
> 
> for uploading a file try
> http://www.nodeworks.com/asp/cgi.html
> at the bottom of the page this contains all of the info on using ASP and CGI
> to upload a file.
> 
> 
>> But I also need to upload a file with this form.
>> When I add ENCTYPE="multipart/form-data" to the form tag,
>> I can only retrieve the first selected item from aSelectField.
>> It's like the wantarray doesn't work anymore.
>> 
>> Does anybody know how to fix this ?
>> 
>> Anton.
>> 
>> -----------------------------------------------------
>> - WestSite NV - I N T E R N E T  S O L U T I O N S  -
>> -----------------------------------------------------
>> Torhoutse Steenweg 337
>> 8200 Brugge
>> BELGIUM
>> T.+32 50 39 41 41
>> F.+32 50 39 41 43
>> mailto:anton@westsite.be
>> -----------------------------------------------------
>> http://www.westsite.be
>> http://wap.westsite.be
>> -----------------------------------------------------
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
>> For additional commands, e-mail: asp-help@perl.apache.org
>> 
>> 
> 
> 
> _______________________________________________________
> J.C. Fant IV
> PlanetofMusic.com
> Perl Guru ?
> 818 517 4879
> mailto:jfantiv@hotmail.com
> _______________________________________________________
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> For additional commands, e-mail: asp-help@perl.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: problem with multiple select

Posted by JC Fant IV <jf...@hotmail.com>.
you can do two different things..

> Hi,
>
> I'm having problem to get the result of a <SELECT ... MULTIPLE> field in a
> form.
> something like this works file :


1.) change the form from method=post to method=get
        <FORM name=FormName method=get>

and the code should work. However if you want to upload a file you are going
to need to use  the second example.

>    <FORM name=FormName method=post>
>      <SELECT name=aSelectField size=4 multiple>
>          <OPTION value=one>first</OPTION>
>          <OPTION value=two>second</OPTION>
>          <OPTION value=three>third</OPTION>
>        </SELECT>
>    </FORM>
>    <P>aSelectField2 : <%

2. to grab the incoming post information Use

        $Request->Form('aSelectField');
this will pull in the posting form.

>      @selectFields = $Request->Params('aSelectField');
>      print join ',', @selectFields
>    %>
>    </P>
>

I tried this code on my server and works fine.

test1.html =
<FORM  action="test2.html" name=FormName method=post>
     <SELECT name=aSelectField size=4 multiple>
         <OPTION value=one>first</OPTION>
         <OPTION value=two>second</OPTION>
         <OPTION value=three>third</OPTION>
       </SELECT>
    <input type="submit" name="submit" value="submit">
   </FORM>

test2.html =

 <P>aSelectField2 : <%
     @selectFields = $Request->Form('aSelectField');
     print join ',', @selectFields
   %>
   </P>


test2.html returned

aSelectField2 : one,two,three
#########

for uploading a file try
http://www.nodeworks.com/asp/cgi.html
at the bottom of the page this contains all of the info on using ASP and CGI
to upload a file.


> But I also need to upload a file with this form.
> When I add ENCTYPE="multipart/form-data" to the form tag,
> I can only retrieve the first selected item from aSelectField.
> It's like the wantarray doesn't work anymore.
>
> Does anybody know how to fix this ?
>
> Anton.
>
> -----------------------------------------------------
> - WestSite NV - I N T E R N E T  S O L U T I O N S  -
> -----------------------------------------------------
> Torhoutse Steenweg 337
> 8200 Brugge
> BELGIUM
> T.+32 50 39 41 41
> F.+32 50 39 41 43
> mailto:anton@westsite.be
> -----------------------------------------------------
> http://www.westsite.be
> http://wap.westsite.be
> -----------------------------------------------------
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> For additional commands, e-mail: asp-help@perl.apache.org
>
>


_______________________________________________________
J.C. Fant IV
PlanetofMusic.com
Perl Guru ?
818 517 4879
mailto:jfantiv@hotmail.com
_______________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: problem with multiple select

Posted by Joshua Chamas <jo...@chamas.com>.
JC Fant IV wrote:
> 
> So here is what I cam up with. Looks to me like you will not be able to do
> both at the same time.
> Multiple select boxes are not pulling in with a from
> ENCTYPE=="multipart/form-data".
> 

I have this fixed in my dev version 2.15.  If anyone wants
it, let me know.  The diff was:

]]]] diff ASP.pm~ ASP.pm
2911c2911,2912
<                   $form{$_} = $q->param($_);
---
>                   my @params = $q->param($_);
>                   $form{$_} = @params > 1 ? [ @params ] : $params[0];

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks <- Web Link Checking          Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: problem with multiple select

Posted by JC Fant IV <jf...@hotmail.com>.
So here is what I cam up with. Looks to me like you will not be able to do
both at the same time.
Multiple select boxes are not pulling in with a from
ENCTYPE=="multipart/form-data".

I would be curious to know if anyone else has gotten this to work.

I attached an asp file for you to try. below is the code. I had to a.)
either post the information to two different pages. or b.) I chose to post
the file upload to itself and send the multiple select to a separate page.
If you want to see this in action try
http://www.planetofmusic.com/test1.html sorry I'm not actually loading any
of your files to my server, but I did test it and it worked correctly.  All
files uploaded were placed in the select box then multiple selects could
then be shown on the second page.  try it???

<%
 my $filehandle = $Request->Form('attfile');
 my $name;
 my $hidden;
 my $option;

 if ($filehandle){
  print $filehandle . "<br>"; # will get you the file name

  #will give you a name for the file;
  $filehandle =~ /(\w+)\.(\w+)/;
  $name = "$1.$2";
  $hidden .= '<input type="hidden" name="' . $name . '" value="' . $name .
'">' . "\n";
  $option .= '<OPTION value="' . $name . '">' . $name . '</OPTION>' . "\n";

  print "This is the name $name<br>";
  my $data;
  while(<$filehandle>) {
   $data .= $_;
  };

  #don't really want people uploading thing right now.
  #uncomment this to store them for yourself.
  #open (fh, ">$name");
  #print fh $data;
  #close fh;

  my $form = $Request->Form();
  foreach (keys %$form){
   if ($_ =~ /(\w+)\.(\w+)/){
    $hidden .= '<input type="hidden" name="' . $_ . '" value="' .
$form->{$_} . '">' . "\n";
    $option .= '<OPTION value="' . $form->{$_} . '">' . $_ . '</OPTION>';
   }
  }
 }
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>Untitled</title>
</head>

<body>
<br>
Notice the first form posts to itself.<br>
<FORM name="doattach" id="doattach" action="test1.html" method="post"
ENCTYPE="multipart/form-data">
<%= $hidden %><br>
I posted hidden variable here.<br>
Attach File: <input name="attfile" type="file"><br><br>
<input type="submit" name="submit" value="Attach File">
</form>





<br>
<br>
The second form posts to the second page.
<form name="doattach" id="doattach" action="test2.html" method="post">
<%= $hidden %><br>
I posted hidden variable here.<br>
and all options below.
<SELECT name="aSelectField" size="4" multiple>
<%= $option %>
</SELECT><br>
<input type="submit" name="submit" value="submit">
</FORM>




----- Original Message -----
From: "Anton Slabbinck" <an...@westsite.be>
To: <as...@perl.apache.org>
Sent: Thursday, June 07, 2001 6:48 AM
Subject: problem with multiple select


> Hi,
>
> I'm having problem to get the result of a <SELECT ... MULTIPLE> field in a
> form.
> something like this works file :
>    <FORM name=FormName method=post>
>      <SELECT name=aSelectField size=4 multiple>
>          <OPTION value=one>first</OPTION>
>          <OPTION value=two>second</OPTION>
>          <OPTION value=three>third</OPTION>
>        </SELECT>
>    </FORM>
>    <P>aSelectField2 : <%
>      @selectFields = $Request->Params('aSelectField');
>      print join ',', @selectFields
>    %>
>    </P>
>
> But I also need to upload a file with this form.
> When I add ENCTYPE="multipart/form-data" to the form tag,
> I can only retrieve the first selected item from aSelectField.
> It's like the wantarray doesn't work anymore.
>
> Does anybody know how to fix this ?
>
> Anton.
>
> -----------------------------------------------------
> - WestSite NV - I N T E R N E T  S O L U T I O N S  -
> -----------------------------------------------------
> Torhoutse Steenweg 337
> 8200 Brugge
> BELGIUM
> T.+32 50 39 41 41
> F.+32 50 39 41 43
> mailto:anton@westsite.be
> -----------------------------------------------------
> http://www.westsite.be
> http://wap.westsite.be
> -----------------------------------------------------
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> For additional commands, e-mail: asp-help@perl.apache.org
>
>
_______________________________________________________
J.C. Fant IV
PlanetofMusic.com
Perl Guru ? Don't Think So!!!!
818 517 4879
mailto:jfantiv@hotmail.com
_______________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: problem with multiple select

Posted by JC Fant IV <jf...@hotmail.com>.
Seems to me that its not the fileupload part that's messed up... its in the
ENCTYPE="multipart/form-data" .

I tried even to submit the multiple select with out using the file upload
with a form tag......
<form name="doattach" id="doattach" action="test2.html" method="post"
ENCTYPE="multipart/form-data">
and I get the same thing, only one select value comes in... I really don't
think its on the Apache-ASP side.... Hey I have been wrong before and am
probably wrong again!!!


----- Original Message -----
From: "Joshua Chamas" <ay...@yahoo.com>
To: "Anton Slabbinck" <an...@westsite.be>; <as...@perl.apache.org>
Sent: Thursday, June 07, 2001 2:24 PM
Subject: Re: problem with multiple select


> There may be a bug here ... Apache::ASP handles
> file uploads with different logic from other forms
> by using CGI.pm for the underlying file upload
> parsing.  I'll look into this ( early next week )
> and see if I can't make multiple select values behave
> properly in this context.
>
> --Josh
>
> --- Anton Slabbinck <an...@westsite.be> wrote:
> > Hi,
> >
> > I'm having problem to get the result of a <SELECT ... MULTIPLE> field
> > in a
> > form.
> > something like this works file :
> >    <FORM name=FormName method=post>
> >      <SELECT name=aSelectField size=4 multiple>
> >          <OPTION value=one>first</OPTION>
> >          <OPTION value=two>second</OPTION>
> >          <OPTION value=three>third</OPTION>
> >        </SELECT>
> >    </FORM>
> >    <P>aSelectField2 : <%
> >      @selectFields = $Request->Params('aSelectField');
> >      print join ',', @selectFields
> >    %>
> >    </P>
> >
> > But I also need to upload a file with this form.
> > When I add ENCTYPE="multipart/form-data" to the form tag,
> > I can only retrieve the first selected item from aSelectField.
> > It's like the wantarray doesn't work anymore.
> >
> > Does anybody know how to fix this ?
> >
> > Anton.
> >
> > -----------------------------------------------------
> > - WestSite NV - I N T E R N E T  S O L U T I O N S  -
> > -----------------------------------------------------
> > Torhoutse Steenweg 337
> > 8200 Brugge
> > BELGIUM
> > T.+32 50 39 41 41
> > F.+32 50 39 41 43
> > mailto:anton@westsite.be
> > -----------------------------------------------------
> > http://www.westsite.be
> > http://wap.westsite.be
> > -----------------------------------------------------
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> > For additional commands, e-mail: asp-help@perl.apache.org
> >
> >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35
> a year!  http://personal.mail.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> For additional commands, e-mail: asp-help@perl.apache.org
>
>

_______________________________________________________
J.C. Fant IV
PlanetofMusic.com
Perl Guru ? Don't Think So!!!
818 517 4879
mailto:jfantiv@hotmail.com
_______________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: problem with multiple select

Posted by Joshua Chamas <ay...@yahoo.com>.
There may be a bug here ... Apache::ASP handles
file uploads with different logic from other forms
by using CGI.pm for the underlying file upload
parsing.  I'll look into this ( early next week )
and see if I can't make multiple select values behave 
properly in this context.

--Josh

--- Anton Slabbinck <an...@westsite.be> wrote:
> Hi,
> 
> I'm having problem to get the result of a <SELECT ... MULTIPLE> field
> in a
> form.
> something like this works file :
>    <FORM name=FormName method=post>
>      <SELECT name=aSelectField size=4 multiple>
>          <OPTION value=one>first</OPTION>
>          <OPTION value=two>second</OPTION>
>          <OPTION value=three>third</OPTION>
>        </SELECT>
>    </FORM>
>    <P>aSelectField2 : <%
>      @selectFields = $Request->Params('aSelectField');
>      print join ',', @selectFields
>    %>
>    </P>
> 
> But I also need to upload a file with this form.
> When I add ENCTYPE="multipart/form-data" to the form tag,
> I can only retrieve the first selected item from aSelectField.
> It's like the wantarray doesn't work anymore.
> 
> Does anybody know how to fix this ?
> 
> Anton.
> 
> -----------------------------------------------------
> - WestSite NV - I N T E R N E T  S O L U T I O N S  -
> -----------------------------------------------------
> Torhoutse Steenweg 337
> 8200 Brugge
> BELGIUM
> T.+32 50 39 41 41
> F.+32 50 39 41 43
> mailto:anton@westsite.be
> -----------------------------------------------------
> http://www.westsite.be
> http://wap.westsite.be
> -----------------------------------------------------
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
> For additional commands, e-mail: asp-help@perl.apache.org
> 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org