Still no working rating display

I think there are enought explanations and tutorials about how you can build a review box. Reviewing is not that hard to understand but it is very hard to understand how you shall code for star rating. My rating stars doubles or triples up for each click and that is not how it´s ment to be. It also seems that it is a more difficult procedure when it comes to ratings on dynamic pages. Especially if you use a repeater which makes the same rating display and numbers being shown in all containers. This is one of my pages and you are free to click on a rating star to the right to see what happends with the display to the left. Also notice what happends in the other containers: https://www.swederotica.com/heterosex Yes it´s an erotic site but with no nude content yet so there is no risk for sensitive persons :wink:

This is the code for that rating. As you can see I have put export function above the onReady functions because else I get the text that import and export functions shall be at the top level of the page. Shall I ignore that warning or not?

export function ratingsInput1_change ( event )
{ console . log ( ‘Inside ratingsInput1_change event’ , event );

$w . onReady ( function () {

$w ( “#dataset2” ). onReady (() =>

{ let $item = $w . at ( event . context ); //Get context of clicked rating
const newRating = $item ( “#ratingsInput1” ). value ; //Get rating value 1-5
console . log ( "New rating = " , newRating );
const currentItem = $w ( “#dataset2” ). getCurrentItem ();
console . log ( 'currentItem = ’ , currentItem );

const average = currentItem . heterosexRatings ;
const count = currentItem . heterosexNumber ;
const total = currentItem . heterosexTotal ;
console . log ( 'average, count, total = ’ , average , count , total );

const newAverageLong = ( total + newRating ) / ( count + 1 );
console . log ( 'newAverageLong = ’ , newAverageLong );
const newAverageShort = Number . parseFloat ( newAverageLong ). toFixed ( 1 );
console . log ( 'newAverageShort = ’ ,

newAverageShort ); $w ( ‘#dataset2’ ). setFieldValues ({
‘heterosexRatings’ : newAverageShort ,
‘heterosexTotal’ : total + newRating ,
‘heterosexNumber’ : count ,});
});
$w ( ‘#dataset2’ ). save (). catch (( err ) => {
console . log ( 'could not save new rating, err = ’ , err );
});
});
});