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

I have a cgi form that requires an email address. If the user neglects to put one in, the program regenerates the original form, but tries to retain those fields that the user did address. I can get text and comment inputs to reprint, but cannot figure out how to do radio buttons, check boxes, and drop down lists (I have both single and multiple drop down lists). Thanks in advance for any advice. Bob

Replies are listed 'Best First'.
Re: Retaining Input
by chromatic (Archbishop) on Nov 14, 2000 at 06:17 UTC
    Use CGI to create your widgets, like $query->radio_group or $query->checkbox_group.

    By default, they're sticky, meaning that it remembers the selected values and maintains them through sessions.

(crazyinsomniac) Re: Retaining Input
by crazyinsomniac (Prior) on Nov 14, 2000 at 09:33 UTC
    I didn't do it, but merlyn did, check it out here.

    "cRaZy is co01, but sometimes cRaZy is cRaZy".
                                                          - crazyinsomniac

Re: Retaining Input
by cephas (Pilgrim) on Nov 14, 2000 at 06:35 UTC
    I've actually implemented something like this before for static forms html forms.

    The solution I came up with was an object that was a subclass of HTML::Parser. It was passed a CGI which held all of the info about what had been selected (I was keeping this info around in a database, so that I could pull up any form at anytime and repopulate it with its last info for that user), and then as I parsed through the html, when I hit an input field (or select fields), I would start filling them in with the appropriate info.

    All of this worked off of the field names, so I could actually pull up a different form with the same field names, and populate it.

    I Suppose that wasn't much of a technical answer, but maybe it will give you some ideas on how you might want to implement something yourself.

    Let me know if you want more info on how I did it.


    cephas