Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Interactive Rating Component

Abdullah 340

@ASH2001prince

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Unfortunately I had a problem when I wanted to prevent the the procedure if there was no number been selected, Any ideas ?

Community feedback

Account Deleted

Hi!

First of all - very well made solution, congrats! 😊

When it comes to your question, you can have a look at my solution for this project.

I placed a conditional statement inside of a for each loop that went through all of the grades. If none of the elements contained an 'active' class (I used it to add the background color and 'choose' the element), an error would appear and the card would not switch to the thank you page.

Hope you find it helpful!

Marked as helpful

1

Abdullah 340

@ASH2001prince

Posted

@jsabram you did a great job on your project, and I have learned a lot form it :)

0
Ahmed 340

@AhmedLebda

Posted

to prevent submitting the rate if the user didn't choose a rate, you can simply add a condition in your event handler for the submit button event, for example :

btn.addEventListener("click", () => { if(!finalValue) { return false } else { valueS.textContent = finalValue; secondCard.style.display = "flex"; firstCard.style.display = "none"; } });

The condition means if the user didn't choose a rate so the finalValue variable is equal to undefined (undefined values === false) the function will just return false otherwise the button submits the rate (when user choose a rate)

Marked as helpful

0

Abdullah 340

@ASH2001prince

Posted

@AhmedLebda actually that worked so good, thank you bro

0
Luis 290

@Poebyt13

Posted

I assumed that the button didn't work like this:

button = document.getElementById("button").disabled = true;

then when you press a number the button will be able to use it

button.disabled = false;

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord