Capturing and Displaying Ratings Error with Dropdown ID

Hello,

I followed the Corvid Tutorial: Capturing and Displaying Ratings step by step but still am unable to get the ratings feature to work properly.

I made sure that my collection’s permissions allow for user input.

Also, the dataset is set to read & write.

I have added the three number fields to my collection:

  • Average rating

  • number of ratings

  • sum of ratings

The Ratings Display element connected to the new Number fields in my collection.

The only difference from the instructions and what I did is that there was no “onChange” so I tried adding the code to first the “onMouseIn” and then on “onClick” but I was unable to get either to work on live site.

The only error that my code is showing is on line 30, it says that the dropdown ID is not valid. I have tried many different combinations and this is the only line that I am unable to change the red dot error message on. Am I using the incorrect ID???

Here is the code I used:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
$w.onReady( function () {
//TODO: write your page related code here…
});
export function ratingsDisplay1_click(event) {
$w(“#restaurantdata”).onReady(() => {
// get the current item from the dataset
const currentItem = $w(“#restaurantdata”).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(‘#ratingsdisplay1’).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(‘#restaurantdata’).setFieldValues({
‘averagerating’: newAverageShort,
‘sumofRatings’: total + newRating,
‘numberofRatings’: (count + 1)
});
// save the dataset fields to the collection
$w(‘#restaurantdata’).save()
. catch ((err) => {
console.log(‘could not save new rating’);
});
});
}

Here is a link to the page I am trying to add this function to:
https://www.glutenfreesocialite.com/Restaurants/Flower-Child

My goal is to get user input to add their rating if they have tried the restaurant by clicking on the rating bar, so far I have not had much luck adding this. Please help!

See this example:

Ratings by User
Let logged-in users rate recipes and edit their ratings.

Hi I have seen that before but wasnt able to get much help from it. Where can I find my dropdown ID? This is the only step that I seem to be missing. I put in what I assume is the dropdown ID 9I have a screenshot of it above) in the code but it is saying it is not a valid value.