Reputation: 7195
populated by options (country list) using Protype:
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);
}
now i need to make option to be selected by value, somethhing like
function selectByValue(countryCode) {
// make option selected where option value == countryCode
}
how to do it with Prototype?
Upvotes: 2
Views: 12403
Reputation: 516
To answer your question, "ho do you do it with Prototype" more directly, change:
document.getElementById('country').value=countryCode
to...
$('country').value = countryCode;
They both do the same thing, though.
Upvotes: 7