1
我有這樣的對象:創建形式從包含對象選擇值
var options = {1: 'Running', 2: 'Falling', 3: 'Collapsing wall',
4: (...)};
我想創建窗體的選擇元素與此對象採取ooptions,所以類似的東西(代碼我想這是不工作,但你可以得到的想法):
html = '<form action="" ><select name="block-action"><option>-------</option>';
for(k in obj){
html += '<option value="'+k+'">'+obj[k]+'</option>'
}
html += '</select></form>'
@ down-voter:小心解釋爲什麼?這個答案如何不正確? – user113716 2011-02-12 23:34:15
該死的,我試圖在控制檯中,並沒有工作。現在就像一個魅力。謝謝:) – marks34 2011-02-12 23:35:19