Could anyone please provide a JSFiddle Demo for me with an implementation?
I have the following HTML code below. I want to record in an array in javascript the the radio button I clicked. Say if I choose the first radio button id="white1"
, the array should store the integer '1'. I am a beginner in javascript so any help would be appreciated!
<body>
<div id="container">
<div id="overlay">
<form action="">
<input type="radio" name="white" value="1" id="radio1"/>
<input type="radio" name="white" value="2" id="radio2"/>
<input type="radio" name="white" value="3" id="radio3"/>
<input type="radio" name="white" value="4" id="radio4"/>
<input type="button" id="continue" value="Continue"/>
</form>
</div>
<div id="base">
<video controls>
<source src="videos/event_0_Junli_Standing_20150322_181647_00_0.6.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</div>
<script>
var arr = []
document.getElementById("continue").addEventListener("click", function() {
var cbChecked = document.querySelectorAll('[name="white"]:checked')
if (cbChecked != null) {
arr.push(cbChecked.value)
}
console.log(arr)
})
</script>
</body>