User Input Ratings- not saving

Hi anyone, need some help. I am going to post my code, ive gotten to the point where the input rating is entered but doesnt save, not to the database and doesnt update on the display side. There are 3 different ratings elements on same page.

$w.onReady(()=> {
//TODO: write your page related code here…

});

export function ratingsInput1_change(event) {$w(“#paiduser”).onReady(() => {
// get the current item from the dataset
const currentItem = $w(“#paiduser”).getCurrentItem();

// get the current average rating, number of ratings, and
//total ratings for the current dataset item
const average = currentItem.avg;
const count = currentItem.numRatings;
const total = currentItem.totalRatings;

// get the new rating from the ratings input
const newRating = $w(‘#overall1’).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
$w(‘#paiduser’).setFieldValues({
‘averagerating’: newAverageShort,
‘sum’: total + newRating,
‘number’: (count + 1)
});

// save the dataset fields to the collection
$w(‘#paiduser’).save()
. catch ((err) => {
console.log(‘could not save new rating’);
});
});
}

export function ethics1_change(event) {$w(“#paiduser”).onReady(() => {
// get the current item from the dataset
const currentItem = $w(“#paiduser”).getCurrentItem();

// get the current average rating, number of ratings, and
//total ratings for the current dataset item
const average = currentItem.avg;
const count = currentItem.numRatings;
const total = currentItem.totalRatings;

// get the new rating from the ratings input
const newRating = $w(‘#ethics1’).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
$w(‘#paiduser’).setFieldValues({
‘averagerating’: newAverageShort,
‘sum’: total + newRating,
‘number’: (count + 1)
});

// save the dataset fields to the collection
$w(‘#paiduser’).save()
. catch ((err) => {
console.log(‘could not save new rating’);
});
});
//Add your code for this event here:
}

export function volume1_change(event) {$w(“#paiduser”).onReady(() => {
// get the current item from the dataset
const currentItem = $w(“#paiduser”).getCurrentItem();

// get the current average rating, number of ratings, and
//total ratings for the current dataset item
const average = currentItem.avg;
const count = currentItem.numRatings;
const total = currentItem.totalRatings;

// get the new rating from the ratings input
const newRating = $w(‘#volume1’).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
$w(‘#paiduser’).setFieldValues({
‘averagerating’: newAverageShort,
‘sum’: total + newRating,
‘number’: (count + 1)
});

// save the dataset fields to the collection
$w(‘#paiduser’).save()
. catch ((err) => {
console.log(‘could not save new rating’);
});
});

}

You’re not passing any object into the save function…

Hi, thanks, but im not a coder so not sure what passing an object means?

TY

Can you point or give an example of where in the code requires an object?

@isofundingreviews Did you get an answer to your question? I am having a similar problem.

Try looking at the examples already provided by Wix as they will tell you how to do all this.
https://support.wix.com/en/article/corvid-tutorial-capturing-and-displaying-ratings
https://support.wix.com/en/article/corvid-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site

Old post being closed.