I'm working on a web-based app and have recently added CGI::Ajax to deal with form submissions that need different sets of parameters in different cases. The display side of it works great - as I make selections from the static controls, the appropriate additional controls appear, seeded with the correct data (where applicable), and I can interact with them normally.

However, when I submit the form, only the values of the static fields are sent back. The controls which were added dynamically via CGI::Ajax seem to be ignored. Further details:

The relevant section of the static page source is
<tr><form name=orderform action=crystomere.cgi method=get> <td></td> <td colspan=3> <input type=hidden name=action value=issueorder> <input type=hidden name=id id=unitid value=1891233> <select name=ordertype id=ordertype size=1 style="width:100%" On +MouseUp="order_params(['ordertype', 'unitid'], ['orderparams']);"> <option value=halt>Halt <option value=attack>Attack <option value=capture>Capture <option value=move>Move <option value=rest>Rest <option value=wait>Wait </select> <div id=orderparams></div> </td> <td style="vertical-align:bottom"><input type=submit value='Issue +Order'></td> </form></tr>
Selecting, say, a "Wait" order causes CGI::Ajax to send back the text
<table width=100% border=0> <tr><th width=10%>Duration</th><td><input type=text name=duration styl +e="width:100%"></td></tr> </table>
(which is inserted into the "orderparams" div) but a "submit" then GETs crystomere.cgi?action=issueorder&id=1891233&ordertype=wait - action, id, and ordertype are there, but duration is nowhere to be found.

The Firefox DOM inspector shows that the new field is present, it is within the form tags, and it is named as expected. On the advice of a Java junkie friend, I tried changing the submit control to a plain button which did a JavaScript alert showing the value of the CGI::Ajax-added control, then using JS to perform the actual submit; the alert displayed the correct value, but the value was still not sent back to the server.

I'm pretty well out of ideas on this one. As far as I can determine, everything looks right, both on the Perl side and the HTML side. I assume it must be possible to create new form inputs with CGI::Ajax and have them submitted with the rest of the form, so what am I missing here?

In reply to Submitting forms with CGI::Ajax-created fields by dsheroh

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.