Changing iframe src using JavaScript: Troubleshooting
You are having an issue with changing the src attribute of an iframe when a radio button is clicked. To rectify this problem, it's essential to examine your code to identify the exact cause. One plausible issue is the incorrect use of brackets.
In your code, the line:
document.getElementById['calendar'].src = loc;
is likely causing the issue. The correct syntax should be:
document.getElementById('calendar').src = loc;
In JavaScript, to retrieve an element using getElementById(), you need to pass a string parameter within single quotes, not brackets. By using the correct syntax, you can ensure that the JavaScript code correctly identifies the iframe by its id and updates its src attribute accordingly.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3