in reply to Getting all values from a CGI list box

Is there a way I can get all the values listed in the list box, whether or not they are selected?

Probably not. When a HTML form is submitted, it usually does not carry this additional information, but only the selected values in the various form widgets/components.

Generally, to get all those list values, you will have to read the HTML of the form and parse it to find the list box if the page is static. Because if the page is dynamically filled via JavaScript, you will have to mimick the browser's behavior to get the list.

But if you're designing the page, like jettero said, you may arrange things to get the value list sent with the submitted data form and then do what you want with this information. That can be done for example with a little bit of Javascript and some hidden form component.

  • Comment on Re: Getting all values from a CGI list box

Replies are listed 'Best First'.
Re^2: Getting all values from a CGI list box
by rashley (Scribe) on Jan 02, 2007 at 18:48 UTC
    "That can be done for example with a little bit of Javascript and some hidden form component."

    Yeah, this is what I was trying to do, but can't seem to stuff a J/S filled array into a param.

    Thanks for the info, though.

      You'll need to serialize them (join them together into one string) in JS, then deserialize them (seperate them back into a list) in Perl.

        He might as well use perl to create his hidden form field value using the same array as in the scrolling_list call.

        For (de)serializing the stuff he can make good use of the code you++ provide on your scratchpad. ;-)

        I was afraid you were going to say that :^\

        With this data, my delimiter is going to be rediculous.

        Thanks.