in reply to Need Help With Writers Block
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.
|
|---|