Create form select from object containing values
Posted
by
marks34
on Stack Overflow
See other posts from Stack Overflow
or by marks34
Published on 2011-02-12T23:21:05Z
Indexed on
2011/02/12
23:25 UTC
Read the original article
Hit count: 200
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>'
© Stack Overflow or respective owner