0

Here is the code

for (var i = 0; i < jsonArr.length; i++) {
    var obj = jsonArr[i];
    htmlText += '<option value="'+obj.place+'">' + placeName + '</option>';
}

I want to show Images as well as place name on the option tag dynamically?

mic4ael
  • 7,974
  • 3
  • 29
  • 42
  • Possible duplicate of http://stackoverflow.com/questions/2965971/how-to-add-a-images-in-select-list. – Koen Jan 04 '17 at 10:45
  • In short: no, you need to use a javascript plugin/ or write your own code that emulates a select box with divs/plain html – Joel Harkes Jan 04 '17 at 10:46

1 Answers1

-1

from your question, you mentioned as

for(var i=0;i<jsonArr.length;i++){
                    var obj = jsonArr[i];
                    htmlText += '<option value="'+obj.place+'">'+placeName+'</option>';
                }

this is not possible, you need to use plugins

try this:

<option value="vaulue_in_integer" id="ID" style="background: url(imageName.png) right no-repeat; width: ABCpx; height: ABCpx">DEMO_TEXT</option>
Pratik Pitale
  • 1,655
  • 1
  • 16
  • 30