Star Rating With HTML CSS & JS

  Рет қаралды 22,686

CodingDesign

CodingDesign

Күн бұрын

Пікірлер: 57
@1989filip1
@1989filip1 Жыл бұрын
Great Work.Thank you so much from Germany😃😃
@CodingDesign
@CodingDesign Жыл бұрын
Thanks for watching! keep l❤ving & supporting.
@nirajnarkhede7552
@nirajnarkhede7552 Жыл бұрын
Beautiful ! love it
@CodingDesign
@CodingDesign Жыл бұрын
Thank you! 😊
@nightsofartsandhearts1320
@nightsofartsandhearts1320 2 жыл бұрын
so simple and clean. Love it!
@CodingDesign
@CodingDesign 2 жыл бұрын
Thank you! 😊 Keep l❤ving & supporting.
@dannyprodig6256
@dannyprodig6256 2 жыл бұрын
thank you
@CodingDesign
@CodingDesign 2 жыл бұрын
You're welcome. I do hope you'll show same l❤ve & support in the future too.
@shashiwanniarachchi5055
@shashiwanniarachchi5055 Жыл бұрын
Can i put transform to them when i click the star i will rotate can i add it to this
@CodingDesign
@CodingDesign Жыл бұрын
Yes you can 👍.
@lianlopez2680
@lianlopez2680 Жыл бұрын
I need to create a page where there are different images and there will be a system of stars, how and what must I do in order to achieve that system of stars
@CodingDesign
@CodingDesign Жыл бұрын
Suppose you have "MULTIPLE DIV" with class name "product-card" For 📝CSS code, you can give your own style. 📝HTML Code ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ 📝JS Code const product_cards = document.querySelectorAll('.product-card'); for(const product_card of product_cards){ const Stars = product_card.querySelectorAll('.star_rating .star'); Stars.forEach((star, i) => { star.onclick = function () { let current_star_level = i + 1; // You can send "current_star_level" variable to DATABASE as a "rating value". allStars.forEach((star, j) => { if (current_star_level >= j + 1) { star.innerHTML = '&#9733'; } else { star.innerHTML = '&#9734'; } }) } }) }
@klaasjanssen644
@klaasjanssen644 2 жыл бұрын
thx nice video
@CodingDesign
@CodingDesign 2 жыл бұрын
Glad you liked it!
@princessdaiane
@princessdaiane 2 жыл бұрын
Hi, could you teach me how to make one with vote counting? Congratulations on the work. you teach very well 😊
@CodingDesign
@CodingDesign 2 жыл бұрын
Thank you 🙏. I might create separate video on "Vote Counting".
@princessdaiane
@princessdaiane 2 жыл бұрын
@@CodingDesign I will wait anxiously. Thank you!
@kennethkim1221
@kennethkim1221 Жыл бұрын
Hi :) I'm new to web development and currently doing Lightning Web Component development. I'm trying to implement this but whenever i load the page it says "allStars is not defined"
@CodingDesign
@CodingDesign Жыл бұрын
Please check variable name's spelling carefully. If you've used "allStars" as variable name then check whether you have use "allStars" or not. That "capital S" might cause this ⚠ error. 📢 So, you can "Change ALL" "allStars" variable name (word) into "all_stars" (you can give anything that is relivant).
@mattuskovac
@mattuskovac 2 жыл бұрын
i have a question.. what if i wanna use this code under multiple let´s say product cards? is it going to work if i copy-paste it under each individual html card section? will always work only on first product card. is there any solution to make it work on every product card? thx
@CodingDesign
@CodingDesign 2 жыл бұрын
☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ //Suppose you have divs with class name "product-card" const product_cards = document.querySelectorAll('.product-card'); for(product_card of product_cards){ const allStars = product_card.querySelectorAll('.star_rating .star'); allStars.forEach((star, i) => { star.onclick = function () { let current_star_level = i + 1; // You can send "current_star_level" variable to database as a rating value. allStars.forEach((star, j) => { if (current_star_level >= j + 1) { star.innerHTML = '&#9733'; } else { star.innerHTML = '&#9734'; } }) } }) }
@omkarsatav2626
@omkarsatav2626 2 жыл бұрын
Thank you
@CodingDesign
@CodingDesign 2 жыл бұрын
You're most Welcome!
@Pat3kz
@Pat3kz 5 ай бұрын
@CodingDesign Could you share the actual code you got in the video for us to use. Thank you
@Pat3kz
@Pat3kz 5 ай бұрын
How to redirect to a form or website upon click??
@CodingDesign
@CodingDesign 3 ай бұрын
You can create anchor tag button.
@EAGLE_KSA
@EAGLE_KSA Жыл бұрын
How can I make evaluation rate?
@CodingDesign
@CodingDesign Жыл бұрын
I've create dedicated video on this topic. ✅ kzbin.info/www/bejne/pWLMhKyQaradesk
@ErrorFrag
@ErrorFrag Жыл бұрын
❤❤❤
@CodingDesign
@CodingDesign Жыл бұрын
Thank you!
@DynamicshopFr
@DynamicshopFr 2 жыл бұрын
Hello, Sorry for bothering you, I have an issue when I click on a star, there is border, how can I do to remove this border? I am not good at java script. Thnaks
@CodingDesign
@CodingDesign 2 жыл бұрын
In 📝 CSS code, for class star if you give Outline 'none', you won't face that problem. Something like this 🔗 .star { outline : none; }
@rubygreen1249
@rubygreen1249 2 жыл бұрын
.star:focus{ outline: none; } for anyone else that comes along this issue
@paivank8823
@paivank8823 2 жыл бұрын
@@rubygreen1249 hey man, can u help me build a star rating for a project im working on for college?
@rubygreen1249
@rubygreen1249 2 жыл бұрын
@@paivank8823 I am just barely getting to server side scripting myself. I needed this tutorial to build a reviews page for a client who is a family member. That being said I don't mind making friends in the profession 🙂
@chiragbhanderi
@chiragbhanderi 2 жыл бұрын
I am getting error of "cannot set properties of null" i am placing script properly even thought plz help
@CodingDesign
@CodingDesign 2 жыл бұрын
I'm sure you've misspell your "class_name" or "id_name". Please check your spelling.
@chiragbhanderi
@chiragbhanderi 2 жыл бұрын
@@CodingDesign Does it works if we used same javascript for 2 html pages and transfer the results to next page ??
@CodingDesign
@CodingDesign 2 жыл бұрын
@@chiragbhanderi Yes it'll work. But what do you mean transfer results to next page, I didn't get you😟. What kind of project are you currently working on?
@ashrafusama3663
@ashrafusama3663 2 жыл бұрын
Hi, I need to connect this with database by php How??
@CodingDesign
@CodingDesign 2 жыл бұрын
If you've knowledge about AJAX or JavaScript Fetch API, you can easily interact with database and the data generated with JS code. Something like : let data = { data : current_star_level } 1️⃣ For IE8+ var request = new XMLHttpRequest(); request.open('POST', '/custom/url', true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); request.send(data); 'OR' 2️⃣For modern browsers 🌎 fetch('custom/url', { method : 'POST', data, 'content-type' : 'application/x-www-form-urlencoded; charset=UTF-8' })
@ekeminigodwin1739
@ekeminigodwin1739 Жыл бұрын
Mine flashes when i click it. Why?
@CodingDesign
@CodingDesign Жыл бұрын
What do you mean flashes?
@classicalrahul7489
@classicalrahul7489 Жыл бұрын
source code please
@CodingDesign
@CodingDesign Жыл бұрын
Sorry I'm unable to provide that.
@saulomesquita1
@saulomesquita1 Жыл бұрын
When I click on the stars nothing happens on my INSPECTION(F12) it shows that: index.html:27 Uncaught TypeError: Cannot set properties of null (setting 'innerText') at star.onclick (index.html:27:42) star.onclick @ index.html:27 in VSCODE 5 star rating How was your experience? &#9734 &#9734 &#9734 &#9734 &#9734 0 of 5 const allStars = document.querySelectorAll('.star'); let current_rating = document.querySelector('.current-rating'); allStars.forEach((star, i) =>{ star.onclick = function(){ let current_star_level = i + 1; current_rating.innerText = `${current_star_level}of 5`; allStars.forEach((star,j)=>{ if( current_star_level >= j+1) { star.innerHTML = '&#9733'; }else{ star.innerHTML = '&#9734'; } 5 >= 1,2,3,4,5 }) } }) when i delete the line: current_rating.innerText = `${current_star_level}of 5`; back to normal but without the star count.
@CodingDesign
@CodingDesign Жыл бұрын
When you're selecting class .."current rating".. let current_rating = document.querySelector('.current-rating'); REMOVE ❌ '.current-rating' ADD ➕ '.current_rating' Did you get the difference❓ " - " vs " _ " And also REMOVE ❌ 5 >= 1,2,3,4,5 that was just for understanding.
@daliaanghel9093
@daliaanghel9093 Жыл бұрын
Hello, I have the below code, but is not working. Please help me, because I tried many things, but I can't find where is the problem . I have *{user-select: none;} for the entire page. Demos They help you to understand how to use certain concepts in making decisions ☆ ☆ ☆ ☆ ☆ 0 of 5 What if? Scenarios that help you understand what differences in results you get with different inputs ☆ ☆ ☆ ☆ ☆ 0 of 5 Did you know? Facts and particularities about businesses ☆ ☆ ☆ ☆ ☆ 0 of 5 Oddities in business Strange facts and practices in companies ☆ ☆ ☆ ☆ ☆ 0 of 5 Inquisitive minds Things you can only discover when you dig deeper into the data ☆ ☆ ☆ ☆ ☆ 0 of 5 Tips & Trick They are not exactly shortcuts to improve your activity, but they are helpful ☆ ☆ ☆ ☆ ☆ 0 of 5 const allStars = document.querySelectorAll('.star_rating'); for(const allStars of allhold) { const Stars = allhold.querySelectorAll('.star'); let current_rating = document.querySelector('.current_rating'); Stars.forEach((star, i)=>{ star.onclick = function () { let current_star_level = i+1; current_rating.innerText ='$(current_star_level)' of 5; allStars.forEach((star, j) =>{ if (current_star_level >= j+1){ star.innerHTML= '&#9733'; }else{ star.innerHTML='&#9734'; } }) } }) } Thank you.
@CodingDesign
@CodingDesign Жыл бұрын
I think you didn't check comments of this 🎬video. One of my 👁‍🗨viewer raised similar ❓question and I've given answer. But anyway, I've found some ⚠mistakes in your code. 🙏Please check out with this code. const star_ratings = document.querySelectorAll('.star_rating'); for(const star_rating of star_ratings) { const stars = star_rating.querySelectorAll('.star'); stars.forEach((star, i) => { star.onclick = function () { let current_star_level = i + 1; // You can send "current_star_level" variable to database as a rating value. star.querySelector('.current_rating').innerText =`${current_star_level} of 5`; stars.forEach((star, j) => { if (current_star_level >= j + 1) { star.innerHTML = '&#9733'; } else { star.innerHTML = '&#9734'; } }) } }) }
@daliaanghel9093
@daliaanghel9093 Жыл бұрын
@@CodingDesignThank you, but it still doesn't work and I copied the code and pasted it directly in the htm file.
@CodingDesign
@CodingDesign Жыл бұрын
@@daliaanghel9093 If you haven't create separate file for JavaScript then Replace all your previous with the that I've given. And be sure to Paste code inside tag. If there is any ⚠Error in Browser's console let me know.
@daliaanghel9093
@daliaanghel9093 Жыл бұрын
Hello, I found out which the problem was. I have on the same page multiple star rating systems and it was necessary to create different set of variables for each rating system (It's not allowed to redeclare the same variable) . Also I had to use current_rating.innerText = current_star_level.toString() + " of 5"; insead of current_rating.innerText =`${current_star_level} of 5`; Thanks anyway for the answer @@CodingDesign
@romaoasis123
@romaoasis123 Жыл бұрын
The allStars.forEach doest work for me: 1 2 3 4 5 const allStars = document.querySelectorAll('.star'); allStars.forEach((star, i) => { star.onClick = function () { console.log(star); console.log(i); } })
@romaoasis123
@romaoasis123 Жыл бұрын
with this code works: const allStars = document.querySelectorAll('.star'); allStars.forEach((star, i) => { star.addEventListener('click', () => { console.log(star); console.log(i); }); });
@CodingDesign
@CodingDesign Жыл бұрын
❌star.onClick ✅ star.onclick When you're adding 🖱"Click" event handler, Did you notice the difference❓
@voquoctrong5304
@voquoctrong5304 Жыл бұрын
ty so much
@CodingDesign
@CodingDesign Жыл бұрын
You're welcome. Keep l❤ving & supporting.
Create And Download Any File On Click Of Download Button
13:36
CodingDesign
Рет қаралды 4,6 М.
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 100 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
How to Make a Star Rating Component in React
16:06
Eric Murphy
Рет қаралды 58 М.
Star Rating System in HTML CSS & JavaScript | CodingNepal
16:02
CodingNepal
Рет қаралды 106 М.
Hide CSS & Protect JavaScript Code
9:13
CodingDesign
Рет қаралды 8 М.
CSS Tips And Tricks I Wish I Knew Before
12:12
Lama Dev
Рет қаралды 492 М.
Learn CSS Animations In 20 Minutes - For Beginners
21:22
Slaying The Dragon
Рет қаралды 1,1 МЛН
Responsive Web Design without Media Queries | CSS Tips & Tricks
14:10
Rating Systems in HTML, CSS, and JS
15:50
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 23 М.
Build A Responsive Sidebar Menu in HTML, CSS, & Javascript - Beginner
30:16
How to take control of Flexbox
16:01
Kevin Powell
Рет қаралды 142 М.
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 100 МЛН