Loop through select values with image

Loop through select values with image

Hi, i have a select box which accepts multiple selections ( Bootstrap Select) when an option is selected i want to display an image. The image part i have done! It successfully echo's an image based on the value.

But how do i loop through the options so it shows multiple images when more than 1 option is selected.

  1. $(document).ready( function() {
  2. $("#PrimaryTrade").each(function () {
  3. $(this).on('changed.bs.select', function (e) {
  4. $("img[name=image-swap]").attr("src","/images/icons/" + $(this).val() + "_Image.png");
  5. });
  6. });
  7. });