Okay, I'll try to simplify this as much as possible.

I have a CGI template that dynamically creates a table based on an array of userids. Next to each userid there is a checkbox. At the bottom is a submit button.

When the submit button is clicked I need the template to send a list of the checked userids back to a CGI page. My plan is to loop through the checkboxes and cat each to a hidden field using Javascript.

Problem is, I don't know how to do any of this, since I've never used Javascript and am still fairly new to CGI.

Right now my template for the form looks something like this (I've removed a lot that isn't relavent to my question):

<body visited="red" bgcolor="#ffffff" leftmargin="0" marginwidth="0" t +opmargin="0" marginheight="0" onload="currentPage();getSortStatus();" +> <table border="0" cellpadding="0" cellspacing="0" width="100%"> {?@userids --?} <tr id="row{?$_x?}" {?if $_v!=1 --?}style="display:none"{?-- $ +_v?}> <td id="username{?$_x?}" <a name="{?$USER_FIRST_NAME?} {?$ +USER_MIDDLE_INITIAL?} {?$USER_LAST_NAME?}"></a></td> <td id="check{?_x?}" <input type="checkbox" name="printcheck" +value="on"></td> </tr> {?-- @userids?} <tr> <td><input type="submit" value="Submit"></td> </tr> </table>
This displays what I want to see, but obviously doesn't do what I need it to do. I know I need a function to call onSubmit, but I don't know how to loop through a dynamically generated series of checkboxes.

So, the questions I pose to the almighty Monks are: 1. What do I need to add to the code above and 2. What will my function look like in order to pass my list of userids?


In reply to OT? Checkbox list with CGI/Javascript by rashley

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.