[Tutor] Passing data from html to py

Vicki Stanfield vicki at stanfield.net
Thu Mar 24 03:28:47 CET 2005


I have one last question on this particular script. I am using the
following line to print out the post data:

for key in form:
                print "%s: %s<br>" % (key, form[key].value)

It works fine except for when the key is to a list object made by the
following select statement:

<select id="prod[]" name="prod[]" multiple="multiple" size="4">
        <option id="MB" name="MB">Motherboards</option>
        <option id="CPU" name="CPU">Processors</option>
        <option id="Case" name="Case">Cases</option>
        <option id="Power" name="Power">Power Supplies</option>
        <option id="Mem" name="Mem">Memory</option>
        <option id="HD" name="HD">Hard Drives</option>
        <option id="Periph" name="Periph">Peripherals</option>
      </select>

AttributeError: 'list' object has no attribute 'value'
      args = ("'list' object has no attribute 'value'",)

How does one traverse a list object to get the selected data?

Thanks for any help.
Vicki



More information about the Tutor mailing list