In the following test2.html code user does multiple selection. When Submit is pushed,the selections are passed correctly to an array in test2.pl. (e.g. cis100cis200) However, if I pass this array in test2.pl to test3.pl as a hidden filed as a hidden field, only the first entry out of the selection is received by the array in test3.pl. (e.g. cis100) I wonder why and how to fix this problem ? Thanks.
file name: test2.html <html> <body> <form name="form1" method="post" action="/cgi-bin/test2.pl"> <select name="class" size="4" multiple> <option value="cis100">CIS100</option> <option value="cis200">CIS200</option> <option value="cis300">CIS300</option> <option value="cis600">CIS600</option> <option value="cis700">CIS700</option> </select> <input type="submit" name="submit" value="Submit"> </form> </body> #file name: test2.pl use CGI qw(:standard); print "Content-type:text/html\n\n"; @class= param('class'); print "<html><body>"; foreach $a (@class) { print "$a<br>"; }; print <<EndForm; <form name="test3" method="post" action="/cgi-bin/test3.pl"> <input type="submit" name="submit" value="Submit"> <input type="hidden" name=class value =@class> </form> EndForm print "</body></html>"; #file name: test3.pl use CGI qw(:standard); print "Content-type:text/html\n\n"; @class= param('class'); print "<html><body>"; foreach $a (@class) { print "$a<br>"; }; print "</body></html>";

In reply to passing array from form to form by bmcc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.