My for loop creates and populates radio buttons from data within an array, when I run the loop it creates the input element then applies array data and continues, through debugging or inspecting the DOM.
The data expected is within the element but won't display in any browser, I'm embedding script and loading bootstrap, I can't understand why?
HTML:
<form name="formName">
<div class="form-group" id="demo">
<label for="exampleFormControlSelect1">Select Course</label>
</div>
<button onClick="DisplayTex()" class="btn btn-primary" type="button">Display</button>
</form>
Javascript:
var course = ["Software Engineering", "Computer Science", "Interactive Multimedia", "Information Communication Technology"];
var courseVal = ["softW", "compS", "InterM", "iCT"];
function DisplayTex(){
if (document.getElementById("university").value == "uniUlster"){
for (var i = 0; i < course.length; i++) {
//text += course[i] + "</input> <br>";
var input = document.createElement('INPUT');
input.type = 'radio';
input.textContent = course[i];
var x = 0;
x++
for(var y = 0; y < x; y++){
input.value = courseVal[y];
}
document.getElementById("demo").appendChild(input);
}
}
}
I still have more to debug with the nested for loop but firstly its getting the array course to display elements on the browser.