Adding some code as you asked in comment.
<option value="2">Country< /option>
You need the value of the option which has Country
in innerHTML
.
Get all options by title
attribute instead of id
as id
always generates dynamically.
var allOptions = document.querySelectorAll("[title=Category] option");
Now find Country
and set as selected.
var allOptions = document.querySelectorAll("[title=Category] option");
[].some.call(allOptions, function(option) {
if (option.innerHTML == "Country") {
option.selected = "selected";
return true;
}
});
PS: Assuming Category
is the name of the lookup column. Need to change in your case.
document.querySelector("[title=ColumnName]").value = IndexOftheCountry;