Thunderfist Posted June 2, 2017 Author Share Posted June 2, 2017 Just now, Jinz said: NUM_QUESTIONS must be intialized to the number of questions that are being summed. I want to sum up the values of all 11 questions in my quiz. Quote Link to comment Share on other sites More sharing options...
Thunderfist Posted June 2, 2017 Author Share Posted June 2, 2017 I just of rid of the error! All I did was change the value of i in for (i = 0; i <NUM_QUESTIONS; ++i) from 0 to 1. Quote Link to comment Share on other sites More sharing options...
Taz Posted June 2, 2017 Share Posted June 2, 2017 Using my example you would just need to set NUM_QUESTIONS to 11 and name the questions "q0", "q1", ..., "q9", "q10" Quote Link to comment Share on other sites More sharing options...
Taz Posted June 2, 2017 Share Posted June 2, 2017 Just now, Thunderfist said: I just of rid of the error! All I did was change the value of i in for (i = 0; i <NUM_QUESTIONS; ++i) from 0 to 1. That works if your questions are named "q1" through "q11", but then you should change the condition to <= otherwise you will only sum "q1" through "q10" Quote Link to comment Share on other sites More sharing options...
Thunderfist Posted June 2, 2017 Author Share Posted June 2, 2017 2 minutes ago, Jinz said: That works if your questions are named "q1" through "q11", but then you should change the condition to <= otherwise you will only sum "q1" through "q10" They are 'q1' through to 'q11'. I still need to get it to send people to a different page when the submit button is pressed. --EDIT-- I just realized that I probably should do that. --EDIT-- Just fixed it so it did sum up all 11. Quote Link to comment Share on other sites More sharing options...
Taz Posted June 2, 2017 Share Posted June 2, 2017 4 minutes ago, Thunderfist said: They are 'q1' through to 'q11'. I still need to get it to send people to a different page when the submit button is pressed Then should set NUM_QUESTIONS to 11 and change < to <= My last example shows how to send to different pages, the one with index.html, resul1.html, and result2.html. It shows how to use if/else to determine which page to send to. Do like that after the for loop that computes the sum. Quote Link to comment Share on other sites More sharing options...
Thunderfist Posted June 2, 2017 Author Share Posted June 2, 2017 Ok. got it. I was just about to test that. Quote Link to comment Share on other sites More sharing options...
Taz Posted June 2, 2017 Share Posted June 2, 2017 Cool, let me know how goes - almost there I thnk Quote Link to comment Share on other sites More sharing options...
Thunderfist Posted June 2, 2017 Author Share Posted June 2, 2017 It worked! but only on result pages 1 and 2. --EDIT-- I just made some minor adjustments. That fixed it! I got it working! Thanks for the help. Taz 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.