I am stuck with something which I cannot figure out and might need some assistance, I'm not an expert in JS
I have a JSON being formatted based on the click of a radio button and this works perfectly fine
I then took up this piece of code and included this in my main html I get the below in the console and the function doesn't work as well
Uncaught TypeError: Cannot read property 'value' of null
http://jsfiddle.net/8kdraw9L/1/
I'm probably missing out on something
<script>
var element = document.getElementById("urls").value;
var obj = JSON.parse(element);
var rad = document.querySelectorAll('.radio');
for (var i = 0; i < rad.length; i++) {
rad[i].addEventListener('change', function() {
selection = this.value
obj["response"]["headers"] = {
"Content-Type": selection
}
document.getElementById("urls").innerHTML = JSON.stringify(obj, undefined, 4);
});
}
<script>