Sneaks

I did a small modification to your code and came up with:

<div id="quiz">
        <ol>
                <li><strong>What is apple in french?</strong>
                        <ol>
                                <li><input type="radio" name="q1" value="0" /> Pomme 
de terre</li>
                                <li><input type="radio" name="q1" value="0" /> 
Poire</li>
                                <li><input type="radio" name="q1" value="0" /> 
Appeaux</li>
                                <li><input type="radio" name="q1" value="1" /> 
Pomme</li>
                        </ol>
                        <a href="#" class="quiz-next">Next</a>
                </li>
        </ol>
</div>

<div id="result">please select your answer and click next</div>

<script type="text/javascript">

        $(document).ready(function(){
                $('#quiz ol li:first').show('slow');
        });

        
        $('a.quiz-next').bind('click', function() {
if ($ (this ).prev ("ol ").children ("li").children("input[type='radio']:checked").attr("value")=="1") {
                        $("#result").text("correct");
                } else {
                        $("#result").text("wrong");
                }
        });

</script>

This works.

what you can do is set the value to be "0" for incorrect and "1" for correct and test for that.


Ady

On 19/12/2008, at 11:30 AM, sneaks wrote:


http://paste.pocoo.org/show/95986/

simple quiz function if the radio in li.correct is checked, then the
user has selected the correct answer from a multiple choice set.

right now i am getting a true no matter which radio is selected in the
group

thanks for any help in advance thhis one has been bugging me for a
while now!

j



Adrian Gould
Adrian dot J dot Gould at gmail dot com

Reply via email to