I have a piece of code that normally looks like this
jQuery("#dealer-selection-" + elm.id).on("click",function(){
selectDealer(jQuery(this).val());
});
Basically what it does is select a radio button that is required for a checkout form.
I want this radio button to be activated from the start, ready to submit.
I have tried the following:
jQuery('.forhandlerRadio:first').attr('checked', 'checked');
and I've also tried putting in
checked="checked"
Into the radio button itself. Both of these things graphically check the radio button, as in they fill in the black dot, however when submitting the form it asks for the radio button to be clicked still.
I deleted the previously mentioned code to test if that was what checked if it had been clicked
jQuery("#dealer-selection-" + elm.id).on("click",function(){
selectDealer(jQuery(this).val());
});
This was correct, as without that code, the form cannot be completed, even if clicking the radio button. That's why I tried making it auto clicked using:
jQuery("#dealer-selection-" + elm.id).trigger("click",function(){
selectDealer(jQuery(this).val());
});
This is, just like the other two things I've tried, able to graphically click the radio button for me, but it still does not count as clicked. Any help is appreciated! The code is from a custom retailer plugin, and the checkout form is the basic woocommerce one.
function selectDealer(id){ jQuery("#dealer-id").val(id); }