Design comparison
Solution retrospective
I had a problem with "back to project" checkoboxes. How to set only one checkbox being available to choose at the time? I would by greateful to get some feedback on it, and also if you could give me some overall feedback too! Thanks :)
Community feedback
- @pikapikamartPosted over 3 years ago
Hey, I see that issue. Well to fix it is kinda simple. What you do is that you put a
name
attribute in each of the radio buttons. What it does is, it groups the radio buttons and if you select one, then select another, the former will be unselected and the latter will be selectd. Just put aname
attribute on the inputs, and make sure that they have the samename
attribute name, like thisname="radio"
all of it must have that attribute^1@pikapikamartPosted over 3 years ago@pawel975 Your welcome and remember to commit your changes so that we could see it as well^
2@pawel975Posted over 3 years ago@pikamart Solution updated :) Checkboxes works fine but my styling don't refer to the change of pledge option. I tried to do some state management to update styling while updating choosen option but it doesnt't work how it should be.
0@pikapikamartPosted over 3 years ago@pawel975 I see that as well, okay here's a better one. Instead of adding an event in your toggles right, upon seeing your js code, what it does, when clicked right, it returns a
div
element with happens to be the price input. But it you didn't create a flag whether if another toggle, is toggled hehe. Here's an easy way,- First, create already the accordion thingy the one that you created in react where it will pop up when a radio button is created. Create it already, then just make
display: none
. - You could just use css for this one, but let's js it. When you toggle a radio button right, then apply a display of block, that way they will pop something like that, but that is not enough right. Imagine a user toggles all, then it will break the idea.
- To fix it, you need to add another layer of flag. You may want to add something like
if (pledgeItemSample) {make it display of block} else {make it display of none}
That is just a pseudo but the point is that, a radio button's attribute of
checked
will only be true if it is checked (of course right, sorry for that). So if another one is checked, then by default, the former selected radio button's checked attribute will now be false, because of thename
attribute, because you can only select one right. Well I were to implement this, I would just use css since it much simpler, which I did when I did this challenge. If you need more help just ask in here okay^^1 - First, create already the accordion thingy the one that you created in react where it will pop up when a radio button is created. Create it already, then just make
Please log in to post a comment
Log in with GitHubJoin 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