I have a dynamic radio option that triggers two different arrays to show in a drop down select.
https://jsfiddle.net/carvingpixel/5mcux28z/3/
<form name="frmRadio" id="radio-buttons" action="">
<input type="radio" id="radio-kits" name="option" onclick="change(this)">Kits
<input type="radio" id="radio-starLabs" name="option" onclick="change(this)">StarLabs
<select id="arrays">
<option id="items"></option>
</select>
</form>
<script>
var kits = ["Lego WeDo", "Force & Motion", "Bernoulli's Lift"];
var starLabs = ["Constellations", "Starfields", "Moon"];
function change(radio) {
if (radio.checked && radio.id === "radio-kits") {
for (var i = 0; i < kits.length; i++) {
document.getElementById("items").innerHTML = kits[i];
}
} else {
for (var i = 0; i < starLabs.length; i++) {
document.getElementById("items").innerHTML = starLabs[i];
}
}
}
</script>
I have most of it working but I am stuck on having each item of the array show in the list. Currently, it's showing the last item in the iteration rather than each item.