Hello,
I created html file with Checkbox and i use python
when i check one box and submit i have problem with list

when i check 2 box or more and submit i see the result list like
['120', '104', '12']
i can use "for" to loop the list and do action
but when i check one box i see the result withour list like
120
not ['120']

whe i use for it the loop will be 1 , 2, 0

how can i fix this
Thanks

Recommended Answers

All 4 Replies

this is my example
html code :

<form method="post" action="bb.py">
<input type="hidden" name="do" value="ss" size="20">
        <input name="Checkbox1" value="111" type="checkbox" />aa1<br />
        <input name="Checkbox1" value="112" type="checkbox" />aa2<br />
        <input name="Checkbox1" value="113" type="checkbox" />aa3<br />
        <input name="Checkbox1" value="114" type="checkbox" />aa4<br />
        <input name="Checkbox1" value="115" type="checkbox" />aa5<br />
        <input name="Submit1" type="submit" value="submit" /><br />
</form>

python code

for i in query.getvalue("Checkbox1"):
      print i

if i checked one box the result will be spaces
1 1 1
if i checked 2 box the result will be work
111 112

how can fix it ?

I see this example made by Tkinter
i want do that with native python not any framework or toolkit

i solve it :) by this
i tried to check the result list or not

if isinstance(query.getvalue("Checkbox1"), list):
                for i in query.getvalue("Checkbox1"):
                        print i
else:
                print query.getvalue("Checkbox1")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.