perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "JC Fant IV" <jfan...@hotmail.com>
Subject Re: problem with multiple select
Date Thu, 07 Jun 2001 22:32:54 GMT
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" <anton@westsite.be>
To: <asp@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


Mime
View raw message