Lets see if I get this right. In the view, place this:
<form><input type="hidden" id="xID" name="picID" value=""/></form>
{{=clickme}}
then in the controller:

    for image in imageRows:
        clickme.append(TAG.button(IMG(..image..),_type="button", 
            _onclick="jQuery('#xID').val('%d');ajax('%s', ['picID'])" \
            % (image.id 
,URL('default','functionThatAddsToDatabase',extension='load', 
user_signature=True))) )

calls the function
def functionThatAddsToDatabase():
    # get the image id
       image_id=request.vars.picID


On Monday, March 14, 2016 at 5:20:15 PM UTC-7, Leonel Câmara wrote:
>
> Make a form with a hidden input and a submit button. Display all the 
> images, add javascript so when one image is clicked it becomes "selected" 
> and its id is added to the hidden input (for instance the hidden input can 
> store the values comma separated). Submit the form and in your controller 
> you should have the selected images in the hidden input's name. You can 
> then validate it using something like:
>
> values, error = IS_IN_DB(db, 'pictures.id', multiple=True, 
> delimiter=',')(request.vars.hidden_input_name)
>
> Finally after checking error is None insert the values into choices:
>
> for value in values:
>     db.choices.insert(user_id=auth.user_id, choice=value)
>
>

-- 
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