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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to