In this case, it’s probably because you are using the wrong brackets here:
document.getElementById['calendar'].src = loc;
should be
document.getElementById('calendar').src = loc;
In this case, it’s probably because you are using the wrong brackets here:
document.getElementById['calendar'].src = loc;
should be
document.getElementById('calendar').src = loc;