For the first method, will I be able to essentially map each instance of form values to their database inserts? Kind of like if the user enters 5 days, 5 copies of form fields are made. The first copy maps to the first day, second copy maps to second day, etc?
As for the second method, if I am understanding correctly..if I were to load a set of separate forms via Ajax does that mean I would have to have multiple forms defined therefore I wouldn't be able to generate the instances dynamically? On Monday, January 18, 2016 at 9:03:19 AM UTC-8, Anthony wrote: > > This is a bit complicated. You don't actually want x separate forms, as > you need to be able to submit a single form (so you want x copies of the > input fields, but all wrapped in a single form). If you do that, though, > for each field, you'll get a list of values (one for each copy of the field > in the form). Alternatively, you could change the name of each input to > include the day number. Either way, you'll need custom backend code to > process all the submitted data and do the database inserts. > > Another option would be to load a set of separate forms via Ajax (possibly > as web2py components), and when the user is ready to submit, run some > Javascript that programmatically submits each form separately via Ajax. In > that case, the backend code would be very simple (just a single standard > SQLFORM) -- all the complexity would be in the Javascript. This is a bit > less efficient, as you'll get a separate HTTP request for each day's form. > > Anthony > > On Monday, January 18, 2016 at 11:36:57 AM UTC-5, aetag...@gmail.com > <javascript:> wrote: >> >> Something like this: >> User inputs x amount of days, using jquery I will have buttons of some >> sort that represent x amount of days which appear when the user specifies >> x. They will then be able to click each button, where an instance of the >> form is displayed and they can enter information for that day then they can >> click another day and another instance of the same form generates. Once all >> forms have been filled accordingly, the user then submits the form at once. >> That is, if it is possible to do this way. >> >> I'm trying to take Massimo's example and work with that, only instead of >> specifying a range I need to link it to the form variable where the user >> submits the x amount so that the amount of form instances are created >> dynamically, not much success so far. >> >> On Thursday, January 14, 2016 at 7:02:37 AM UTC-8, Anthony wrote: >>> >>> Are you wanting the user to fill all forms and submit them at once, >>> submit one form at a time (but remaining on the same page in order to >>> submit additional forms), or just submit one of the many forms and then >>> have the page reload/redirect? >>> >>> On Wednesday, January 13, 2016 at 11:58:02 AM UTC-5, aetag...@gmail.com >>> wrote: >>>> >>>> I'm not sure if this is even possible, but if it is..how would >>>> something like this work: >>>> >>>> You prompt the user for an x amount of days, then with javascript and >>>> jquery you have x amount of buttons appear. Each button is an instance of >>>> the form. There is a variable within the javascript that holds the amount >>>> x. So for each instance of x, the user fills out the same form but with >>>> different values for each day. In the db module containing the sqlform, >>>> there is a function that takes in each instance and performs what it needs >>>> to for each separate instance. >>>> >>>> Also, if you are in views, how can you share a variable that is used in >>>> a script to python code in the same views, or in the db models file? >>>> >>> -- 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.