I have a questionnaire (Yes/No questions) on a webpage that I need to create a grease-monkey script for, which will auto-select all "Yes" options (radio buttons with value yes in the page). I created the below script, but when I click the button it only highlights the "yes" option but does not actually click/select it.
Below is the code, which I believe is pretty straightforward. What could be wrong here:
var input=document.createElement("input");
input.type="button";
input.value="GreaseMonkey Button";
input.onclick = showAlert;
document.body.appendChild(input);
function showAlert()
{
var btns = document.querySelectorAll('input[type="radio"]')
for(var i=0;i<btns.length;i++){
if(btns[i].value=="Yes"){
btns[i].checked=true;
}
}
}