Adding multiple ratings to a dynamic page


I’m adding 3 different ratings to my page and I can only get two of them to actually work. RatingsInput1 and 2 both function as desired, but ratingsInput3 won’t work and I can’t work out why.

I copied the code I had for ratingsInput2 that is working and substituted all the bits for the right cells in the collection.

Thank you

export function ratingsInput3_change(event) {
let currentItem = $w(‘#dynamicDataset’).getCurrentItem();
// get the current item from the dataset
// get the current average rating, number of ratings, and
//total ratings for the current dataset item
const average = currentItem.accessibilityAverage;
const count = currentItem.accessibilityCount;
const total = currentItem.accessibility;

// get the new rating from the ratings input 
const newRating = $w('#ratingsInput3').value; 

// calculate the new average rating based on the current 
//average and count 
const newAverageLong = (total + newRating) / (count + 1); 
// Round the average rating to 1 decimal point 
const newAverageShort = Number.parseFloat(newAverageLong).toFixed(1); 

// set the dataset fields to the new average, total 
// ratings, and number of ratings 
    'accessibilityAverage': newAverageShort, 
    'accessibility': total + newRating, 
    'accessibilityCount': (count + 1) 

// save the dataset fields to the collection 
    .catch((err) => { 
        console.log('could not save new rating');