YigalB Posted February 1, 2012 Share Posted February 1, 2012 A math quiz is presented and the user should fill the form cells with the answers. So far I did it with PHP and it works well, until I learned about Ajax existence. But I failed to make it work. I would appreciate an example of code for the following: - A form with two cells for numerical: a, b. - Once the user press "submit", each cell is tested for the expected results: a should be 5, be should be 7 - if a is correct, the boundary of the cell becomes green, and the grade 50% appears in a circle near by. If not, the boundary becomes red and the grade appears 0. - same for b - bellow both appears the final grade a+b in circle - 2 parameters are sent back to the the PHP code: true/false for a, and true/false for Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/256207-how-to-compare-give-grade-and-color-a-quiz/ Share on other sites More sharing options...
Adam Posted February 3, 2012 Share Posted February 3, 2012 We're not here to write your scripts for you. Best advice I can you give you would be to use jQuery - it makes manipulating the DOM and AJAX requests simple. First read up on selectors and events, and how you can use them to get the value of your inputs and capture the form submission. JavaScript is C-based syntax, like PHP, so you should be able to work out the basic syntax for the validation pretty easily. Then for AJAX requests just use the AJAX API. If you get stuck, by all means post what you have so far and we'll go from there. Quote Link to comment https://forums.phpfreaks.com/topic/256207-how-to-compare-give-grade-and-color-a-quiz/#findComment-1313967 Share on other sites More sharing options...
YigalB Posted February 3, 2012 Author Share Posted February 3, 2012 We're not here to write your scripts for you. Best advice I can you give you would be to use jQuery - it makes manipulating the DOM and AJAX requests simple. First read up on selectors and events, and how you can use them to get the value of your inputs and capture the form submission. JavaScript is C-based syntax, like PHP, so you should be able to work out the basic syntax for the validation pretty easily. Then for AJAX requests just use the AJAX API. Thank you for your kind guidance. At this stage I just need an example so I could duplicate and modify according my exact need. Quote Link to comment https://forums.phpfreaks.com/topic/256207-how-to-compare-give-grade-and-color-a-quiz/#findComment-1313991 Share on other sites More sharing options...
Adam Posted February 3, 2012 Share Posted February 3, 2012 The jQuery documentation has a lot of examples. Quote Link to comment https://forums.phpfreaks.com/topic/256207-how-to-compare-give-grade-and-color-a-quiz/#findComment-1313994 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.