I am trying to make a selector component with some of the options. I am not getting any results with this. Something is wrong with the way I’m doing this.
Can anyone help me with this?
var object = {
"id":"countries",
"label":"Country",
"name":"countries",
"type":"select",
"options":[
{
"value":"",
"text":"Select Country"
},
{
"value":"in",
"text":"India",
"selected":"true"
},
{
"value":"us",
"text":"United Stated"
},
{
"value":"uk",
"text":"United Kingdom"
},
{
"value":"cn",
"text":"Canada"
}
]
};
var select = "";
var mapInfo = function (element,info) {
$.map(info, function(val,num){
console.log(val);
})
}
var generateSelector = function (info){
select +='<select'+info.id+'></select>'
select +=mapInfo(select,info.options)
$('body').append(select);
}(object);
Try this:
Demo