rvera / image-picker

Image Picker is a simple jQuery plugin that transforms a select element into a more user friendly graphical interface.
http://rvera.github.com/image-picker
Other
906 stars 216 forks source link

Cant seem to get back image selected #97

Closed scotteureka closed 7 years ago

scotteureka commented 7 years ago

Im trying to find out the image selected, based on the image picked i would then show a div depending on the "band" its in.

I have the below for now but cant seem to get it to work and in particular seems to be failing when trying to get the values from each item any help appreciated:

var _Small = ["product1"]; var _Med = ["product2"]; var _Large = ["product 3"];

jQuery("#btn").click(function(){

//get the image picker ID and see if this returns the selected options var _selected = jQuery ("select").data("picker").selected_values();

var band = 1;

for(i=0; _selected.length; i++){

//Check if the selected option is in one of the bands and then set the band its in if (jQuery.inArray(_selected[i],_Small) != -1){

      if(band == 1)
      band = 1;

}

if (jQuery.inArray(_selected[i],_Med)!= -1){ if(band < 2) band = 2;

} if (jQuery.inArray(_selected[i],_Large)!= -1){

     if(band < 3)
      band = 3;

} }

if(band == 3){

jQuery("#price3").show(); }

})

rvera commented 7 years ago

Can you create a jsfiddle? selected_values should give you the value of the selected options.