Need help on Capturing rating

Wish to collect rating from customers but the value does not update in the dataset, check several times the field name is correct, type also correct, never code before, I copy the code from

https://support.wix.com/en/article/velo-tutorial-capturing-and-displaying-ratings

can anyone help me out here? any other why to do this?

export function ratingsInput1_change ( event ) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
$w ( “#dataset1” ). onReady (() => {
// get the current item from the dataset
const currentItem = $w ( “#dataset1” ). 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 ( ‘#ratingsInput1’ ). 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 ( ‘#dataset1’ ). setFieldValues ({
‘avg’ : newAverageShort ,
‘totalRatings’ : total + newRating ,
‘numRatings’ : ( count + 1 )
});

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

Thanks

The Ratings by User example might be useful for your purposes.

How exactly is this example supposed to help us? There seems to be a lot of us with this same issue and you keep offering up the same example sites. How do we fix the code? How do we make the code work for us? We don’t know how to code, and although we are following the Velo tutorial, its still not working. Have you all thought of doing a video tutorial instead of a vague article? Its going on over a month at the time that I write this that I have been dealing with this issue and Wix/Velo has been NO HELP.

@wegotgreatdeals Wix provides many resources to help users learn how to get the most out of Velo. We encourage users to take advantage of these resources which include video tutorials, full app examples (which can be loaded into the user’s editor), API documentation, and a wealth of articles describing a wide range of topics - from beginner to advanced.

To learn about programming with Velo, read the following articles that will help you start working with Velo:

For those users who need coding assistance, it is possible to find expert developers on the Wix Marketplace an online marketplace with top Velo web developers from around the world.

@wegotgreatdeals Hi Wegot! I have the same problem as you had (or still have) and also think that an easy video tutorial “for dummies” is a must because this is really not easy. In my case the ratings doubles or triples up for each click on stars and nothing have worked to get rid of that dilemma. Did you finally get a working code or are you still struggling with it?

@kricke73 No video tutorial is required as all that’s needed is to use the Ratings by User example which shows precisely what’s needed. I’ve looked at your code and you have numerous errors which I have already pointed out and are still not corrected.

As you state, “this is really not easy”. In order to achieve your goal you will need to spend time learning how to program Velo. Copy and paste is not enough. One needs to understand what is being copied and why.

Use the learning resources that I posted previously and learn how to develop with Velo. Load the Ratings by User example into the Editor, play with it, learn, and then adapt it to your own use. If you need assistance, you can hire an expert from the Wix Marketplace who can help you out.