I was hoping someone could help me out with a problem I've had a hard time solving. What I have is a select box with multiple options. What I'm trying to do is get the all the items the user selected, loop through the array and compare the results and render them to the screen.
for instance, if a user selects LeBron and Kyrie, I know I can get those values in an array with cat1.val(). I know I can use a for loop to cycle through the items, the trouble I'm having is being able to compare multiple results and rendering them to the screen. Any help would be greatly appreciated.
<select multiple id="cat1">
<!-- <option disabled selected>Please Select</option>-->
<option value="lebron">Lebron James</option>
<option value="kyrie">Kyrie Irving</option>
<option value="kevin">Kevin Love</option>
<option value="tristan">Tristan Thompson</option>
<option value="jr">JR Smith</option>
</select>
for(var i = 0; i < $cat1.length; i++){
//if user selects Lebron && kyrie
$contentBlock.html('<h4>Lebron James</h4><h4>Kyrie Irving</h4>');
}
Aucun commentaire:
Enregistrer un commentaire