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

@khuranamanan

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


Hey, I wasn't able to figure out how to make it compulsory for users to select at least one rating button. Any suggestions on how it can be done?

Community feedback

Adriano 34,090

@AdrianoEscarabote

Posted

Hi Manan Khurana, how are you?

I really liked the result of your project, but I have some tips that I think you will enjoy:

  • every Html document must contain the main tag, so we can identify the main content, to fix this, wrap all the content with the main tag. HTML5 landmark elements are used to improve navigation experience on your site for users of assistive technology.
  • Consider using rem for font size .If your web content font sizes are set in absolute units, such as pixels, the user will not be able to re-size the text or control the font size based on their needs. Relative units “stretch” according to the screen size and/or user’s preferred font size, and work on a large range of devices.
  • to remove the scrollbar, we can do this:
body {
    margin: 0;
    padding: 1rem;
}

To make the user have to at least select one button, we can do it in a very simple way:

ratingButtons.forEach((e) => {
    e.addEventListener("click", () => {
        ratingNumber.innerText = e.innerText;
        btnSubmit.addEventListener("click", () => {
            mainContainer.style.display = "none";
            thankYouContainer.style.display = "";
        })
    })
})

The rest is great!

I hope it helps... 👍

Marked as helpful

0

@khuranamanan

Posted

@AdrianoEscarabote Thank You, Adriano, for the feedback. I have made the changes you suggested. 😊

1

@harsh-mohite-09

Posted

Hey Manan, nice work.

It will be even better if user gets an alert if he tries to submit without selecting. Try implementing that.

Design is very close to accurate. Kudos!

0

@khuranamanan

Posted

@harsh-mohite-09 Thanks, Harsh. Will try the alert.

0
funupulu 120

@funupulu

Posted

Hi dude,

do you know that half of your JS script is commentded out?

//Adding Event listner on all rating buttons // ratingButtons.forEach((e)=>{ // e.addEventListener("click", ()=>{ // ratingNumber.innerText = e.innerText; // }) // })

// btnSubmit.addEventListener("click", ()=>{ // mainContainer.style.display = "none"; // thankYouContainer.style.display = ""; // })

0

@khuranamanan

Posted

@funupulu Yes, the commented-out code is the same as the executed one. Just the two lines have been combined ( for submit button to work only when rating button is clicked.)

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