2013-12-19 2 views

답변

0

var select = document.getElementById("selectColor"); 
for (var i = 0; i < colors[i].length; i++) { 
    var opt = colors[i]; 
    var el = document.createElement("option"); 
    el.innerHTML = opt; 
    el.value = opt; 
    select.appendChild(el); 
    console.log(colors); 
} 
을보십시오 : 나는 "정의되지 않은 재산 '길이'를 읽을 수 없습니다 catch되지 않는 형식 오류"는 무엇입니까

function Save() { 
    colors.nextColor.push({ 
    "name": document.getElementById("name").value, 
    "rgb": document.getElementById("colordisplay").innerHTML, 
    "opacity": document.getElementById("div").style.opacity 
}); 

//pass the array into the dropdown list 

var select = document.getElementById("selectColor"); 
    for (var i = 0; i < colors[i].length; i++) { 
    var opt = colors[i]; 
    var el = document.createElement("option"); 
    el.textContent = opt; 
    el.value = opt; 
    select.appendChild(el); 

    console.log(colors); 
} 
} 

: 나는 이것을 시도

function Save() { 
colors.push({ 
    "name": document.getElementById("name").value, 
    "rgb": document.getElementById("colordisplay").innerHTML, 
    "opacity": document.getElementById("div").style.opacity 
}); 
//pass the array into the dropdown list 
var select = document.getElementById("selectColor"); 
    var opt = colors[colors.length-1], 
     el = document.createElement("option"), 
     desc = 'N: ' + (opt.name || 'unnamed') + ' RGB: ' + opt.rgb + ' O: ' + (opt.opacity || '0') ; 
    el.innerHTML = desc; 
    el.value = desc; 
    select.appendChild(el); 
    console.log(colors);} 

변경 : 내가 제대로 이해하면

+0

특히 '

+0

왜 내가하지 않습니까? 경. – HICURIN

+0

'innerHTML'은 매우 느리기 때문에. 그리고 '

0

, 나는에 저장() 함수를 변경 한 것 꽤 자명하다.

관련 문제