The easiest way to handle this is to only allow them to modify one tuple at a time -- present the current list, but not in editable fields, with an 'edit' button next to each one, which will bring up a new window (or frame), and only allow them to add one new item at a time.

An alternate way is to choose a naming scheme for your fields such that you can easily build sets from the names. eg, 'Lat_1' is paired with 'Long_1'. However, in that case, you'll need to go through the list of fields returned ($cgi->param()) to see if there are fields of interest, as opposed to just checking if a certain field is there.

The next alternative requires javascript, which means it might fail horribly for some people -- you can be assured that in DOM, you can keep track of matching pairs of fields, so if one of the fields of interest is modified, you can update a hidden composite field, so you only have to iterate over the composite field, which is assured to be paired correctly (well, assuming they have javascript ... if they don't, you have to fall back to one of the other methods, but you also have to make sure that you pass back that javascript wasn't on, and the hidden fieleds aren't to be trusted. (you could insert the hidden fields through document.write() calls in <script></script> blocks, but I'm not sure that the extra work is worth it)

Although it's fairly safe to assume that the browser will return two sets of the same named fields in the same order, you can't necessarily go through the lists with the same iterator, and assume they'll be pairs -- the browser doesn't have to send empty fields, so an empty value in each list, but in different sets will completely screw up your results.


In reply to Re: Need Help With Writers Block by jhourcle
in thread Need Help With Writers Block by awohld

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.