Hello,

I want help in python for checkbox form
i use this html code

<input name="do" type="checkbox" value="file1" />
<input name="do" type="checkbox" value="file2" />
<input name="do" type="checkbox" value="file3" />
<input name="do" type="checkbox" value="file4" />

-----------

and after submet

for i in query.getvalue("do"):
    print "_%s_<br>" %(i) 

when i check more than 1 file the loop appear good
file1
file2
file4

If i checked one only appear wrong like
f
i
l
e
3

how can fix this
Thanks

You probably have a tuple or a list when you check more than 1 file, and a str or unicode when you check only one file. You could try

val = query.getvalue("do")
if isinstance(val, (str, unicode)):
    val = (val,)
for i in val:
    etc

In python 3, use(bytes, str) instead of (str, unicode).

Thank you very much the peoblem has been solved :)
thanks again for daniweb and your fast responding

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.