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

JavaScript

Can this logic be applied to checkboxes? If so, how?

For instance, you're using the <select> to filter only the books. What if I also had two checkboxes that further filtered 'fiction' and 'non-fiction'?

If I recall, you can have multiple values in your value="" attribute (array?) within the <option> of the <select>. Then you use the checkbox to filter the fiction/non-fiction values.

Steven Parker
Steven Parker
243,656 Points

An element can have only one attribute of each kind, so in this case only one "value" attribute.

1 Answer

Steven Parker
Steven Parker
243,656 Points

Assuming the "filter" you speak of is being done in JavaScript code, you can chain those methods together and use more than one of them. You could also use more than one criteria within the function used by the filter to make the determination.

To make it possible to provide a more specific answer, you could post a link to a workspace snapshot and/or a course video, or post the code itself.