I'm trying to pass an array in an onchange function but running into errors.
The function is in the head tag as:
<script>
function displayReference(rA) {
var rsb = document.getElementById("refSelectBox");
var id = rsb.value;
dr = document.getElementById("display-ref");
dr.innerHTML = '</br>' + rA[id];
return true;
}
</script>
where rA should be an array. I've tried two different ways of sending the rA array through onchange:
1.
<select class="selectResults" id="refSelectBox" onchange=displayReference(this.refArray)>
(produces "TypeError: undefined is not an object (evaluating 'rA[id]')")
2.
<select class="selectResults" id="refSelectBox" onchange=displayReference(refArray)>
(produces "ReferenceError: Can't find variable: refArray").
Through a console.log(refArray) just before producing the select box code, I know that refArray exists and is populated.
If it's any help in providing answers, this is all in the environoment for a MS Word add-in.
Thanks for any help in advance.