I have a radio button that selects a dealer in my checkout. I need this button to automatically be checked for the user - however, no matter what I do, the radio button still needs to be clicked to validate.

Here's what I've tried so far:

document.getElementById("#dealer-selection-" + elm.id).click();

This makes the radio button show up as if it's been clicked, however when submitting form, a notice still pops up with a validation error.

jQuery('.forhandlerRadio:first').attr('checked', 'checked');

Same thing as above - this shows the radio button as clicked, but for the purposes of the submit button, it is not.

jQuery("#dealer-selection-" + elm.id).trigger("click",function(){

Again, this shows the button as clicked, but it is not.

I have even tried simply adding checked="CHECKED" to the radio button itself, which also shows as checked, but does not validate.

Thanks in advance


1 Answer 1


I finally found one that works for me:

document.getElementById("#dealer-selection-" + elm.id).checked=true;

For some reason, this one checks the radio button visually, while also checking it as an option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.