Hello there good people, i am making a website, a movie streaming website, and i would love to have a Rating stars in the Dynamic page (as you know, the Dynamic page is showing “Movie name, Poster, Trailer, Story, Movie 1080p, Movie 480p, and the download buttons”) so this is what the Dynamic page is showing, so when the visitor see a movie and like it, i would like that he will be able to rate it, i added the stars “Rate the movie” and i added “if you recommend it” anyway, how can i connect it to a Database so every one of the visitors can rate ? and it shows for the public how many visitors rated it and etc … ! because for now, it is just a shape ! i can’t use it to rate ! check this if you want to help and thank you in advance
Hello Michael,
You can add a separate dataset that’s connected to a separate database, make sure to use a mutual field field in both the databases, then connect the rating element to the rating dataset, and add the ratings dataset as a filter on the main dataset to display the right ratings.
Another solution is to query the ratings database using the mutual field (must be unique for each movie), here’s how you can do it:
$w.onReady(async function () {
await $w('#moviesDataset').onReady(() => {
let item = $w('#moviesDataset').getCurrentItem();
let movieId = item.movieId;
wixData.query('ratingsDatabase')
.eq("movieId", movieId)
.find()
.then( (results) => {
$w('#movieRatings').rating = results.rating;
$w('#movieRatings').numRating = results.numRating;
})
}
}
That should solve your problem.
For info on WixData Queries and how it work, check out its documentation:
Hope that helped
If you have other questions regarding this topic feel free to reply, if the solution solved your issue, please mark this question as solved by marking this answer as the best answer using the three dots on the right.
Happy Coding.
Ahmad.
thanks for the reply, i will try to see what i can do using the first solution you provided, maybe i can understand it, as you may know, i don’t know what kind of field i should choose for the rating … text ? number ? and what should be connected to what ? ! and which kind of Rating i should use, there is two of them ! and for the code, thank you, but i don’t know how to use codes in wix, i know i should turn on Dev mode, but next ? god knows thanks
Hi Michael,
Depending on your needs, and how do you want the rating behavior to be (editable for instance) you might need additional datasets.
Yes there’s two ratings elements that you can use, one that let’s users rate, and the other is only to display the ratings from a database.
Please follow this tutorial to learn how to capture and display the ratings:
https://support.wix.com/en/article/corvid-tutorial-capturing-and-displaying-ratings
hello again and thanks for the fast reply, i have followed the lesson step by step, but it didn’t worked, maybe because i don’t have onChange ?? i tried to use onClick ? if yes how can i bring that command onChange ?
Hi,
What are you trying to do? What element do you want to add the onChange() event handler on?
Hey again sir, Check this out i have published the page that i made right now, i made a mistake and i didn’t added ratings input in the first time, i added only the ratings display, but now i have added both of them and connected the ratings display, but when i rate the page for example (love it) the rating display don’t show it ! it still showing 150 products ratings ! and when i refresh the page the rating that i made is gone ! and the ratings display is showing nothing as well, hey maybe i am asking something you won’t agree for, but, if you want i can make you admin in the website and you can check what the problem is ? ! then you can explain it here so me and others can get it ? ! anyway, about the lesson it said that i should use onChange and press enter then paste the code, but i didn’t had onChange so i used onClick, this is what i meant … thank you
Michael, the reason you don’t have the onChange event function available to you is because you are selecting the page, hence why you have page1 as the id name.
You need to be selecting the ratings input element on your page for this to have the onChange event function available in the properties panel for it.
thank you GOS and thank you ahmad … as for what you said GOS, yes it was a mistake and yes i clicked on the ratings display it showed the same ! but it was my mistake i have to click on the Ratings Input to see onChange as i saw in your screenshot, and it did worked … thank you both, but, it seems that i can’t use it ! i tried it and i am using it in a Dynamic page as you saw, so this Dynamic page is showing 100’s of movies and this rating i was trying to do to rate every movie by itself ! but this lesson it rating all of the movies in the collection, it is like whatever movie you choose from the gallery it will have the same rate, any way, thank you again
Are you using the tutorial for ratings that was linked to as this is not really setup for working on dynamic pages.?
https://support.wix.com/en/article/corvid-tutorial-capturing-and-displaying-ratings
You might want to look at using the product review tutorial for the Wix Stores and change it to suit your own pages.
https://www.wix.com/corvid/example/product-reviews
You can find previous forum posts on doing that too.
https://www.wix.com/corvid/forum/community-discussion/comments-reviews-on-dynamic-pages
https://www.wix.com/corvid/forum/community-discussion/review-and-rate-dynamic-pages
Finally, check out Yisrael’s example for ratings by user as well.
https://www.grampsworkbench.com/Examples/Ratings-by-User
Hi,
I am beginner and figured out some kind of a solution (although probably not expert level coding) but I have tried to explain it all so that even those who do not know coding can understand/use the code…
I am just posting it here, so if anyone comes across this post, they will see it and it may help them
You mention Page Element: Page1
How do I find it on my dynamic page.
I have dynamic page that came with sections and strips but I cant see the Page1 element.
I also searched for it under the layers in the tools.
Please see the screenshot
Thank you