While training on a website, I attempted to automatically fill a radio button type. However, when I used the code from the site in my Google Chrome console, it returned undefined.
The website:
the html: view-source:https://benalexkeen.com/autofilling-forms-with-javascript/
I am trying to select the third radio button using this code:
var radioElements = document.getElementsByName("input3");
for (var i=0; i<radioElements.length; i++) {
if (radioElements[i].getAttribute('value') == 'Radio3') {
radioElements[i].checked = true;
}
}
Output:https://i.sstatic.net/9TjLg.png
Even after attempting to adjust this code for another website, I continue to receive an undefined output.