Here's what I'm working on: I have CGI interface using OpenThought to display a list of properties and their associated owners along with their ownership share in the property. Of course each property can have a variable amount of owners. Each owner listed has a dynamic input for editing their share value. I'm struggling on how to pass the share parameter as an array through OpenThought. According to CGI documentation, I should be able to retrieve the parameter array at the server with @shares = $query->param('share');, but all I get when calling scalar @shares is 1.

I've determined that the parameters are using the name tag property instead of id. Since I'm using dynamic inputs and am using javascript to caculate the share totals, I'd like to implement the array design...nice and clean. I could just name them uniquely and use some sort of regex to create the array at the server, but then I'd have to redesign the share calculations and retrieving the values at the server would get dirty.

I haven't found any real-life examples of using arrays, jsut the arrays in the documentation...which I can't get to work. I would LOVE to use hashes...but I haven't seen any reference to it. Does anyone have any ideas for me?

#server code sub editShares_save{ my $self = shift; my $q = $self->query; my $OT = OpenThought->new(); my $params; my @names=$q->param; my @Share=$q->param('Share'); warn (scalar @Share)."\n"; foreach(@names){warn 'name='.($_).' value='.($q->param("$_"))."\n";} } #generated HTML form <table class="tablecontent1"> <tr align='right'> <td></td> <td>Share</td><td></td> </tr><tr> <td> - John Smith </td> <td><input type="text" onkeyup="updateShares()" onblur="formatShar +es(this);updateShares()" name="Share" id="ShareD43C272F-FDEA-0D6C-D3E +0-68357BAB6197" value="0.00"></td> <td>% </td> </tr><tr> <td> - Jane Doe </td> <td><input type="text" onkeyup="updateShares()" onblur="formatShar +es(this);updateShares()" name="Share" id="Share2C0C4234-17D2-CFBC-E39 +3-03FDBE78F6F2" value="0.00"></td> <td>% </td> </tr> </table> <input type='button' value='Save' onclick='save();'> <script> function save(){ var answer=confirm('Are you sure you want to modify this ?'); if(answer){ document.getElementById("save").value=1; showWait(1); var data=["id","save","Share*"]; OpenThought.CallUrl(url, data); } } </script>

In reply to CGI/OpenThought array/hash handling by ksublondie

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.