I am trying to write a CGI front end to a database for recipes... I have a lot of it working but I am having trouble with my edit recipe form. The bit that is causing me problems is this:

for (my $i=0; $i<$numberofingredients; $i++) { print "$ingredientAoH[$i]{qty}\n"; print "Qty:", $query->textfield(-name=>"qty$ingredientAoH[$i]{ +ingID}", -default=>"$ingredientAoH[$i]{ +qty}" -size=>'10', -maxlength=>'20', "\n"); print "Amt:", $query->textfield(-name=> "ammount$ingredientAoH +[$i]{ingID}", -default=> "$ingredientAoH[$i] +{amt}", -size=>10, -maxlength=>100, "\n"); print "Des:", $query->textfield(-name=> "description$ingredien +tAoH[$i]{ingID}", -default=> "$ingredientAoH[$i] +{des}", -size=>50, -maxlength=>100), "\n"; print $query->hidden(-name=>"ingID$ingredientAoH[$i]{ingID}", +-default=>"$ingredientAoH[$i]{ingID}"), "<br>\n"; }

Now I put that extra print in there at the top for debugging purposes and it does in fact print out the correct value. However, the actual text field just displays the first whole number. So if I have a value of say 1/4, it just shows up as 1, 1 1/2 shows up as 1, etc... Larger numbers work (ie. 12 shows up as 12) but it doesn't seem to like spaces or slashes. Does anyone know why and what I could do to fix it?

Oh and as an aside, if I type in the correct value and submit it, the correct values go into the database. It just doesn't read them properly as the default values.


In reply to problem with form value (using cgi.pm) by MCS

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.