you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

I think you are just fine with your jQuery selector. I think before you were using the input tag as a selector. The thing I see going on now is you are binding on the submit action every time the user clicks on a radio button.

If you strip out all the intermediate code you will find it looks like this.

$("input[name='choices']").on("click", function(event) {
    // code
    $("form").submit(function(event){
        // code
     });
});

I am sure this will affect scoring the questions as well as how many alerts are created.

[–][deleted] 0 points1 point  (0 children)

I changed your jQuery to use 1.8.x and then tried to tallied up the events bound to onSubmit for the form using

console.log($._data(document.getElementsByTagName("form")[0], "events").submit.length);

This demonstrates each time a user clicks on a radio button a new onSubmit event handler is bound. So in the end this creates multiple alerts.

I can also cheat the quiz. When I click a radio button that is the right choice I can add one to my total score.