2
使用樣機選項(國家列表)填充提供的值來選擇:
for (var i = 0; i < j.length; ++i) {
var opt = new Element('option', {value:j[i].country})
opt.innerHTML = j[i].country_name;
country.appendChild(opt);
}
現在我需要做的選擇由值來選擇,somethhing像
function selectByValue(countryCode) {
// make option selected where option value == countryCode
}
如何用Prototype做到這一點?
奇怪, 的document.getElementById( '國家')。值= COUNTRYCODE 警報(的document.getElementById( '國家')。值) 警報有效 「COUNTRYCODE」,但在組合框中舊的(第一)值仍選中,爲什麼? – Zelid 2009-07-29 10:31:18