gsd4me has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,

A seeker of information rather than a software problem. I have a CGI module, it generates HTML code (fine and dandy) with a form, several types of input (Radio, checkbox, number and text amongst others). Everything works smoothly so far except ...

Running the code on a server (local and 'real') the parameters returned via the POST operation on the SUBMIT button being pressed seem to be a bit bizarre. Viz. no value is returned (correctly) for the checkboxes or radio when they have not been input by the user, but for number or text types, their input "identifier" is returned, albeit with an empty value for the relevant fields (see below with a real value entered by me (5) as a test).

K0010: K0011: K0012: K0028: 5 K0039: K0040: K0041: K0042: finishButton: FINISH

I can program round this fact/anomaly but I simply wondered why those types of Form>Input return their identifiers when no text or values have been selected by the user whereas other types do not. Any sages out there know the answer?

Replies are listed 'Best First'.
Re: CGI - input number fields
by Corion (Patriarch) on Sep 07, 2017 at 20:14 UTC

    I think what you're seeing is that they have an empty value, instead of not being submitted at all. Which somewhat makes sense for (text) input fields, where the user might want to empty out a field.

      I could understand *that* reasoning for a text field, but the number field? They have a specified range of 0 through 5 (and show "no selection" on the initial form display) so to my way of thinking, as the user hasn't even selected the field, no value has even been selected.
        What do you mean by a "number field"? I don't remember anything like that from HTML4.

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: CGI - input number fields
by Anonymous Monk on Sep 07, 2017 at 21:54 UTC

    I have a CGI module, it generates HTML code (fine and dandy) with a form, several types of input (Radio, checkbox, number and text amongst others).

    What module is that?

      Am using HTML::Tiny as it has everything that I need for the simple project.

      I used to use CGI.pm for a lot of my projects but that is now redacted and anyway, there was a feature/bug or two (!) that meant that it didn't behave as it was told to, so I gave it a severe telling off and made it sit on the Naughty Step for a long time.