I tried that last night which fixed the cosmetic issue of it always posting the update message to the top div; however, it still only updates the first record. At least now it says it updates the first record in the correct div though. ;) I am fundamentally misunderstanding how the submit button gets the data to request.vars. No matter what I do, it keeps assigning the first forms data to request.vars. I can't figure out how it is making the decision.
On Jan 26, 10:28 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > because > > <div id="target">{{=i.id}}</div> > > <script> > $('#myform{{=i.id}}').submit(function() { > ajax('{{=URL(r=request,f='new_post')}}',['id', 'test_case', > 'functionality', 'task', 'expected_result', 'test_status', > 'regression', 'comments', 'affects_clients', > 'client_acceptance_test'],'target'); > > should be > > <div id="target{{=i.id}}"></div> > > <script> > $('#myform{{=i.id}}').submit(function() { > ajax('{{=URL(r=request,f='new_post')}}',['id', 'test_case', > 'functionality', 'task', 'expected_result', 'test_status', > 'regression', 'comments', 'affects_clients', > 'client_acceptance_test'],'target{{=i.id}}'); > > Massimo > > On Jan 27, 12:21 am, jlegler <jleg...@gmail.com> wrote: > > > Yea, the formatting gets pretty tore up on here when I post for some > > reason and I haven't been doing it for very long so my code is pretty > > ugly to start with. The code you are looking at will create multiple > > forms; however, request.vars is the same no matter which one I > > submit. It always submits the data on the top most form. I can't > > figure out why for the life of me. Any ideas? I am sorry to waste > > your time on this. > > > -jason > > > On Jan 26, 8:36 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > didn't you just do it? What is the problem. The code is hard to read. > > > > Massimo > > > > On Jan 26, 7:52 pm, jlegler <jleg...@gmail.com> wrote: > > > > > The reason I am asking is because I want to generate a bunch of forms > > > > based on data in the database and have them all show up on the screen > > > > at one time and be updateable. I can get all of the forms to show up > > > > on the screen and I can fill them out; however, they all make the > > > > first one submit. Is there a way make each one submit correctly > > > > without defining all of the forms in the controller? > > > > > The way I am doing it now is defining several forms in html for > > > > several rows in the database: > > > > > <h4>Modify Existing Function Tests</h4> > > > > {{for i in db(db.post.test_case==request.args[0]).select():}} > > > > <form id="myform{{=i.id}}" name="myform{{=i.id}}"> > > > > <textarea name="functionality" id="functionality" > > > > class="functionality" >{{=i.functionality}}</textarea> > > > > <textarea name="task" id="task" class="task" >{{=i.task}}</ > > > > textarea> > > > > <textarea name="expected_result" id="expected_result" > > > > class="expected_result">{{=i.expected_result}}</textarea> > > > > {{=SELECT(test_case_status, value=i.test_status, > > > > _name='test_status', _id='test_status', _class='test_status')}} > > > > <textarea name="regression" id="regression" class="regression"> > > > > {{=i.regression}}</textarea> > > > > <textarea name="comments" id="comments" class="comments"> > > > > {{=i.comments}}</textarea> > > > > {{=INPUT(_type='checkbox', _name='affects_clients', > > > > _id='affects_clients', _class='affects_clients', > > > > _value=i.affects_clients)}} > > > > {{=INPUT(_type='checkbox', _name='client_acceptance_test', > > > > _id='client_acceptance_test', _class='client_acceptance_test', > > > > _value=i.client_acceptance_test)}} > > > > <input name="_formname" type="hidden" value="post{{=i.id}}" /> > > > > <input type="hidden" value="{{=i.id}}" name="id" id="id" /> > > > > <input type="hidden" value="{{=request.args[0]}}" name="test_case" > > > > id="test_case" /> > > > > <input type="submit"/> > > > > </form> > > > > <div id="target">{{=i.id}}</div> > > > > > <script> > > > > $('#myform{{=i.id}}').submit(function() { > > > > ajax('{{=URL(r=request,f='new_post')}}',['id', 'test_case', > > > > 'functionality', 'task', 'expected_result', 'test_status', > > > > 'regression', 'comments', 'affects_clients', > > > > 'client_acceptance_test'],'target'); > > > > return false; > > > > }); > > > > </script> > > > > {{pass}} > > > > > I'm using the ajax function to submit the form to a different > > > > controller which looks like this: > > > > def new_post(): > > > > record=db(db.post.id==request.vars.id).select() > > > > form = SQLFORM(db.post, record[0]) > > > > if form.accepts(request.vars,formname=None): > > > > return '%s updated' % request.vars.id > > > > elif form.errors: > > > > return TABLE(*[TR(k,v) for k,v in form.errors.items()]) > > > > > Does anyone have any ideas on how I can do this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---