You say...

// Ensures that the specified array to hold form elements exists. // This function is needed because browser(s) only automaticaly creates an array // when there is more than one form element with the same name.

I had similar problem with one of my CGI scripts where I had to deal with multiple drop down and radio boxes. The way I was able to make sure that my CGI would always get an array of elements is by simply inserting a hidden form element with the same name. In addition, I also marked a single selection (in the select box) as default. For example, if you had a select field 'foo_choices', you'd need to add this hidden field:

<form ... > <input type="hidden" name="foo_choices"> Make a foo choice: <select name="foo"> <option > ... <!--- leave one option pre-selected by default... ---> </select> </form>
So, when the form is submitted, you'll always have at least two instances of the 'foo_choices' parameter sent to your CGI. The CGI module, seeing this, will build an array. Frankly, I didn't have to resort to complex JS scripts to make this work.

I hope this helps somewhat in your noble effort to reduce the JS rubbish and leave more to Perl! ;-)

_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+) +-.*)$/; $_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"}:{print" +- $1"}&&`rm $1`; print$\;}

In reply to Re: CGI Ensure Array by vladb
in thread CGI Ensure Array by SteveRoe

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.