I am trying to change the value of an input element (url) based on a selected option (facetselection):
<script src="external.js" type="text/javascript"></script>
<script>
function facetselection(e) {
document.getElementById("ebscohosturl").value = e.target.value;
}
</script>
<input id="url" name="ebscohosturl" type="hidden" value="" />
<div id="facets">
<select id="facetselection" onchange="facetselection(event)">
<option id="nofacet" value="new_url" label="הכל">הכל</option>
<option id="facetarticles" value="new_url2" label="מאמרים אקדמיים">מאמרים אקדמיים</option>
<option id="facetbooks" value="new_url3" label="ספרים">ספרים</option>
<option id="facetebooks" value="new_url4" label="ספרים אלקטרוניים">ספרים אלקטרוניים</option>
<option id="facetthesis" value="new_url5" label="תזות">תזות</option>
<option id="facetmaps" value="new_url6" label="מפות">מפות</option>
</select>
</div>
This is based on the solution found here. I also tried this solution. I am getting an error:
Uncaught TypeError: facetselection is not a function
at HTMLSelectElement.onchange
What am I missing? I defined the function in a script element, and I think the syntax is correct.