|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm trying to figure out how to score a quizz using wmlscript. I have the correct/incorrect answer part working, I'm trying to create a function that keeps score by incrementing the value of a variable, I'm not sure what I'm doing wrong.
the script: function addscore(){ var points; points=points++; return points; } extern function validateAnswer(Answer) { var validResponse = WMLBrowser.getVar("Answer"); if (validResponse != "value") { WMLBrowser.go("poll2.wml#NResults"); } else { WMLBrowser.go("poll2.wml#YResults1"); var number = addscore(); WMLBrowser.setVar("score", number); } }; extern function validateAnswer2(Answer){ var validResponse = WMLBrowser.getVar("Answer"); if (validResponse != "value") { WMLBrowser.go("poll2.wml#NResults"); } else { WMLBrowser.go("poll2.wml#YResults3"); var number = addscore(); WMLBrowser.setVar("score", number); } }; The card that's supposed to show the score: <card id="YResults3" title="Results:"> <p> Yes: Answer $(Answer) is correct " </p> <p> Score: $(score) out of 3 " </p> <p> <a href="poll2.wml#Trivia1">Start Over</a> </p> </card> |
|
#2
|
|||
|
|||
|
I would make sure of two things:
(1) That you have the correct initial value of points in the addscore function, and (2) That you are calling the addscore function before you go to the YResults3 card. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > WAP Programming > quizz with wmlscript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|