html - Javascript 2 functions for onClick -


Hello I'm new to javascript so please come along with me. I have a javascript quiz that collects replies and shows scores at the end of the quiz. At the end of the score is calculated on the status of an 'onClick' order, which I want to parse through Google Analytics for Event Tracking. At the moment, when the button is clicked, I will not do this when the value of the score is parsed and parsed according to analytics. The exact same method works if the variable is another defined integer (with a fixed value)

Here is my code:

  var numQues = 5; Var numChoi = 3; Var url = location.href; Var score = 0; Var Answer = New Array (5); Reply [0] = "Play your Pet CD"; Answer [1] = "National Petlog Database"; Answer [2] = "Some types of cancer"; Answer [3] = "A few weeks"; Answer [4] = "up to 1 year"; Function getScore (form) {score = 0; Var currElt; Var currSelection; (I = 0; i & lt; numQues; i ++) for {currElt = i * numChoi; For (j = 0; j & lt; numchoi; j ++) {currSelection = form.elements [currElt + j]; If (currSelection.checked) {if (currSelection.value == Answer [i]) {Score ++; break; }}}} Form.score.value = score + "/" + numQues; Var correctAnswers = ""; (I = 1; i & lt; = numQues; i ++) (right view + = i + ". + + [I-1] + + \" \ r \ n ";} Form.solutions.value = The correct answer;} is the Javascript function () {return (score);}   

and the button is:

   class = "ScoreButton" Onclick = "getScore (this.form); pageTracker._trackEvent ('quiz', 'petcare quiz', url, score);" type = "button" value = "get score" />  < / Pre> 

Any help would be greatly appreciated. Thanks

You do not believe the tracker Sending, try it :

  & lt; input class = "scorebutton" onclick = "doStuff (this.form);" type = "button" value = "get score" />   

Edit:

  function getScore (form) {score = 0; Var currElt; Var for currSelection; for (i = 0; i   

Edit: I have a bit of code I've probably been refacted, maybe it works like this or can get the error.

Comments