On Sep 29, 2005, at 8:50 AM, [EMAIL PROTECTED] wrote:

My app has a Questions Module which has related Module Answers edited
inline (just like in django admin)

Questions can be correct or incorrect and only one question can be
correct for each question.

Whjat I'd like to do is implement a javascript onchange that will set
all other other answers in the form to incorrect when an answer is
marked as correct


Should be pretty easy. I'm going to assume you have models that look something like::

    class Question(meta.Model):
        ...

    class Answer(meta.Model):
        question = meta.ForeignKey(Question, edit_inline=meta.TABULAR)
        is_correct = meta.BooleanField()

So the thing to do is to add a "js" option to your Question model::

    class Question(meta.Model):
        ...
        class META:
            js = ('/path/to/questions.js',)

This will automatically load questions.js on every Question page. From there you can use the DOM to grab all your is_correct fields and install onchange handers.

Good luck!

Jacob

Reply via email to