Good folks, I've had a good hunt through this website and it does appear to me what I've done is correct (it obviously isn't)!
I'm trying to pass multiple select items via cgi but I only seem to be passing the first entry. The html gets formatted correctly (I think) as
<form action="post" name="RunForm"> <input id="env" type="hidden" name="env" value="PROD"/> <select id="runs" name="runs" multiple=""> <option>2010-08-17 ----- 039733</option> <option>2010-08-17 ----- 039753</option> </select> <p> <input type="button" onclick="UntarFiles(env,runs)" value="Combine Fil +es"/> <input type="reset" value="Cancel" name="Cancel"/> </p> </form>
The Javascript called when they onclick is
function UntarFiles() { if (document.RunForm.runs.selectedIndex==-1) { alert("Please make a selection from the list."); return false; } var env = document.getElementById("env").value; var runs = document.getElementById("runs").value; var url = "atlanta_combine_postscript.cgi?&env=" + escape(env) + " +&runs=" + escape(runs); request.open("GET", url, true); request.onreadystatechange = IssueAlert; request.send(null); }
and in the called perl cgi program, to receive the parameters I have
use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my ( $env, @runs ); $env = param('env'); @runs = $query->param('runs');
However whilst what I have in the called perl program may be wrong - since I can see in the error log I'm getting the error "Can't call method "param" on an undefined value"

So the issue I have is that when I select multiple items, I can see that what it is trying to be passed is

atlanta_combine_postscript.cgi?&env=PROD&runs=2010-08-17 ----- 039733
rather than

atlanta_combine_postscript.cgi?&env=PROD&runs=2010-08-17 ----- 0397332010-08-17 ----- 039753

(if indeed that is how I would expect to see multiple items passed in)?
So two questions:
Can anyone see what I've done wrong to only pick up one rather than all selected items
and
Is what I've done to initially receive the data (as an array) correct?
Any help greatly appreciated as ever. Cheers
Kev


In reply to Passing 'SELECT MULTIPLE' parameters and CGI by viffer

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.