JavaScript

Jason Dunbar
Jason Dunbar
4,872 Points

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'?

Matthew Griffith
Matthew Griffith
Full Stack JavaScript Techdegree Student 18,651 Points

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
148,790 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
148,790 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.