Create form select from object containing values
- by marks34
I have such an object :
var options = {1: 'Running', 2: 'Falling', 3: 'Collapsing wall',
4: (...)};
I'd like to create form's select element with ooptions taken from this object, so something like that (code I tried which is not working, but you can get the idea) :
html = '<form action="" ><select name="block-action"><option>-------</option>';
for(k in obj){
html += '<option value="'+k+'">'+obj[k]+'</option>'
}
html += '</select></form>'