Changing iframe src with Javascript

shinjuo picture shinjuo · Sep 16, 2010 · Viewed 432.4k times · Source

I am trying to change an <iframe src=... > when someone clicks a radio button. For some reason my code is not working correctly and I am having trouble figuring out why. Here is what I have:

Answer

Pekka picture Pekka · Sep 16, 2010

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;