Currently, I am in the process of developing a star rating system specifically designed for restaurant reviews. The 'Attributes' displayed on the user interface are dynamic and fetched in JSON format.
There exist five attributes with each having up to 5-star rating options available:
Review Attributes Data:
[
{
"ATTRIBUTEID": "FOODQUALITY",
"ATTRIBUTENAME": "Quality Of Food",
"POSITION": 1
},
{
"ATTRIBUTEID": "CLEANLINESS",
"ATTRIBUTENAME": "Cleanliness",
"POSITION": 2
},
{
"ATTRIBUTEID": "SERVICE",
"ATTRIBUTENAME": "Service",
"POSITION": 3
},
{
"ATTRIBUTEID": "STAFFBEHAVE",
"ATTRIBUTENAME": "Staf Behavior",
"POSITION": 4
},
{
"ATTRIBUTEID": "AMBIENCE",
"ATTRIBUTENAME": "Ambience",
"POSITION": 5
}
];
The goal is to achieve something like this:
https://i.sstatic.net/ZcFA7.jpg
Progress So Far
This dynamic web page generates stars and labels automatically using JavaScript code. Clicking on one attribute's stars should not affect other attribute's ratings.
Edit
I have modified my snippet to create stars and labels dynamically based on the JSON data provided. However, there seems to be an issue where selecting stars from one attribute affects others. Please refer to the static HTML code for comparison.
In the second snippet below, I have included the JavaScript code responsible for generating these dynamic elements but struggling to maintain separate functionality for each attribute selected.
Problem: Changing the selection of stars once marked e.g., moving from 4 stars down to 2 stars, does not reset correctly across different attributes. The desired behavior is to mimic the functionality exhibited in the initial static HTML setup.