Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Brian Weiss
4,693 PointsSelected category choice input not checked
Following along with the video. I cannot get the "If" statement that checks the selected category choice to actually check the box.
I've double checked the cookie, and the value is saving there, like:
"{\"name\": \" Joe \"\054 \"color\": \"blue\"\054 \"shirts\": \"\r\n pink\"\054 \"pants\": \"\r\n stars\"\054 \"hat\": \"\r\n pink-beanie\"\054 \"glasses\": \"\r\n optical-purple\"\054 \"footwear\": \"\r\n sandal-pink\"}"
I can also get the option printing on the screen using {{ saves.get(category) }} as a token.
I've double checked the html markup and the "checked" attribute is not being added to the selected radio option.
I fixed the typo he corrected at the end of the video as well. If it's relevant, I'm not following along in Workspaces, but on my local machine.
'''python
<div class="items">
{% for category, choices in options.items() %}
{% if category != 'colors' %}
<div class="grid-100 row">
<div class="grid-20">
<p class="category-title">{{ category.title()}} </p>
</div>
<div class="grid-80">
<input type="radio" id="no_{{ category }}_icon" name="{{ category }}" value='' {% if not saves.get(category) %} checked {% endif %}>
<label for="no_{{ category }}_icon"><img src="/static/img/no-selection.svg"> </label>
{% for choice in choices %}
<input type="radio" id="{{ category }}-{{ choice }}_icon" name="{{ category }}" value="{{ choice }}" {% if saves.get(category) == choice %} checked{% endif %}>
<label for="{{ category }}-{{ choice }}_icon" ><img src="/static/img/{{category}}-{{choice}}.svg"></label>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
'''