Search code examples
phpjavascriptajaxformsrating

Submitting a rating with Ajax or Javascript together with the rest of the form


I'm creating a form with a PHP/MySQL backend where a user fills out a form for a new product and rates a couple of its aspects while he is at filling out the form.

Now I have been looking for a nice, graphical Ajax/Javascript script (no simple selection box) that allows me to add these ratings to the form, however all of them seem to try to submit the rating to a table RIGHT AWAY (before my actual form has been submitted), which of course doesn't allow it to add the Auto_Incremented PRODUCT_ID together with the rating and the rated field's ID.

Does anyone know how I could submit the rating together with the rest of the form? (updating the PRODUCT_ID in the ratings table after the product has been submitted gives me headaches, and I didn't find any script with nice graphical star ratings that allows to simply submit the ratings together with the rest of the product/form data).


Solution

  • You could try have the "onclick", or what ever method your rating script triggers, create a hidden html input inside the form with the rating value. Have it do that instead of submitting on the user's action. Would be easier to explain if you posted some example code.