[Solved] How can I create a star based feedback system for a website?


You could try something like this:

In your HTML page, pass arrays containing strings to the Javascript change() function based on which stars should be changed. For example:

<img src="https://stackoverflow.com/questions/28414185/star.png" width="20px" height="20px" id="1" onclick="change(['1']);">
<img src="https://stackoverflow.com/questions/28414185/star.png" width="20px" height="20px" id="2" onclick="change(['1', '2']);">
<img src="https://stackoverflow.com/questions/28414185/star.png" width="20px" height="20px" id="3" onclick="change(['1', '2', '3']);">
<img src="https://stackoverflow.com/questions/28414185/star.png" width="20px" height="20px" id="4" onclick="change(['1', '2', '3', '4']);">
<img src="https://stackoverflow.com/questions/28414185/star.png" width="20px" height="20px" id="5" onclick="change(['1', '2', '3', '4', '5']);">

Then, in Javscript, accept the array as an argument in ‘change()’, and iterate over it. For each item (each ‘id’ of a star that must be changed), get the element from the page using the ‘id’ from the array, and set its src attribute to the new image, just like you’ve already done.

Good luck!

solved How can I create a star based feedback system for a website?