[web2py] Re: How to do this? Obviously I need ajax but what's the exact syntax?
No not exactly that Ben the images should go in the view too. It might be easier to simply use checkboxes next to the images if you guys are having a hard time. This way there's no need for hidden fields or javascript. -- 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.
Re: [web2py] Re: How to do this? Obviously I need ajax but what's the exact syntax?
please send me college management system which developed in web2py.. which contain 'student 'staff fees attendence library module On Tue, Mar 15, 2016 at 11:42 AM, Ben Lawrencewrote: > Lets see if I get this right. In the view, place this: > > {{=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. > -- 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.
[web2py] Re: How to do this? Obviously I need ajax but what's the exact syntax?
Lets see if I get this right. In the view, place this: {{=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.
[web2py] Re: How to do this? Obviously I need ajax but what's the exact syntax?
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.