Did anyone have an alternative? On Thursday, October 16, 2014 12:08:18 AM UTC-4, LoveWeb2py wrote: > > UPDATE: This works well for me after the form submits: redirect( > request.env.http_web2py_component_location,client_side=True) > > That came straight from the book, but its when the student gets a question > wrong is where I'm running into trouble. I'd like to just refresh the div > so they could continue to enter answers. > > On Wednesday, October 15, 2014 11:45:39 PM UTC-4, LoveWeb2py wrote: >> >> I tried to search through most of the forums before submitting my >> question but I couldn't seem to find what I was looking for. >> >> When a user submits their answer I would like to do two things: >> >> if it is accepted and its corrected I would like to refresh the page, but >> if its not correct I would just like to refresh the div that has their >> submitted answers. >> >> my controller is: >> >> def submit_answer(): >> answer=FORM('Answer: ', >> INPUT(_name='answer', requires=IS_NOT_EMPTY()), >> INPUT(_type='submit', _class='btn btn-primary', >> _id="sub_button")) >> if answer.accepts(request,session): >> #session.tabTracker = request.vars['chal'] >> answer_comp = db(db.answers.id >> ==int(request.vars['chal'])).select(db.right_answers.ALL).first() >> if answer.vars['answer'] == answer_comp['answer']: >> response.flash = 'Correct! Nice job!' >> else: >> response.flash = 'Incorrect answer' >> elif answer.errors: >> response.flash = 'Please submit your answer' >> else: >> response.flash = '' >> return dict(answer=answer) >> >> and my view: >> {{=LOAD('board','submit_answer.load', >> vars={'chal':question['id']},ajax=True)}} >> >> The name of the div I would like to refresh is: <div >> class="panel-heading"> >> >> I've tried the response.js solution Anthony posted in another forum, but >> it didn't seem to work. >> >> I know web2py has a onclick= feature and I'm thinking thats the way to >> go, but not sure how to structure it >> >
-- 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.