Thank you Val, it works like a champ. I guess my confusion was when I did

type(request.vars.name) it showed me <type 'list'>. So, I didn't realize I 
needed to change that to list again.

I am guessing the one line ids you did is 

if (ids == isinsance(ids,basestring)):
     ids = [ids]
else:
ids = ids

Thank you.

On Sunday, March 20, 2016 at 12:29:52 PM UTC-4, Val K wrote:
>
> ids=request.vars.name
> ids= isinstance(ids, basestring) and [ids] or ids # so it  will be a list 
> in anyway
> ids = [long(id) for id in ids] # just in case
> post_selected= db(db.Post._id.belongs(ids)).select()
>
>
> On Sunday, March 20, 2016 at 12:41:24 AM UTC+3, Ron Chatterjee wrote:
>>
>>
>> I have checkbox and from there I read my ids, which is request.vars.name 
>> generated from a button in view <td><input type="checkbox" name= "name" 
>> value= {{='22' }} /></td>
>>
>>
>> In my controller I use
>>
>> Post_selected           = db.Post(request.vars.name);
>>
>> It works fine if one id is selected lets say '22'.
>>
>> if
>> request.vars.name
>> '22'
>>
>> len(request.vars.name) is  2.
>>
>> but if
>> request.vars.name
>> ['22', '23']
>>
>> len(request.vars.name) = is also 2
>>
>>
>> So, I am having hard time looping through the array and distinguish them.
>>
>> What would be the best way to get all the posts of selected id, ['22'] 
>> and for multiple checkbox selection lets say ['22','23','24'] with 
>> request.vars.name
>>
>> In other words, if my request.vars.name is ['22','23','24'] I get all 
>> the posts associated with the id. If one e.g., '22', then just one.  Thanks 
>> in advance.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to