ids= isinstance(request.vars.name, basestring) and [ids] or ids # so it 
 will be a list in anyway
post_selected= 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to