views:

48

answers:

1

Have a "check"?

For example... I would have a dictionary with the parameters to sent to the POST.

params = {'text':'how are you?', 'subject':'hi'}

then I would have

opener.open('theurl',urllib.urlencode(params))

The question is...those parameters work well with text-boxes, since I just put the value in there. How about radio buttons? How do I signify which is "checked"?

+2  A: 

Radio buttons has values too

<input type="radio" name="music" value="Rock" checked="checked"> Rock<br>
<input type="radio" name="music" value="Pop"> Pop<br>
<input type="radio" name="music" value="Metal"> Metal<br>

for that case {"music":"Rock"} in params

S.Mark
Note if a `value` attribute is omitted and that radio or checkbox is ticked, the submitted value will be `'on'`.
bobince