Jump to content

Recommended Posts

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!

 

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.