Reputation: 343
I'm working on a WC Appointment Bookings product, and I managed to set up a default for a simple numeric field using a custom script:
// Set default value to 0 for Input multiplier (for additional hours)
jQuery(document).ready(function(){
jQuery('.addon-input_multiplier').val("0");
});
But I can't tweak that script to set a radio button to be a default. Here's the HTML of the button I want to make the default...
<p class="form-row form-row-wide addon-wrap-520-language-0-0">
<label><input type="radio" class="addon addon-radio" name="addon-520-language-0[]" data-raw-price="" data-price="" value="spanish" /> Spanish </label>
</p>
For the numeric field, I put the id into the Javascript, but the radio button doesn't have an id. I can't tweak the HTML, because it's generated, and this doesn't seem like something that would require getting into the PHP.
What am I missing?
Upvotes: 0
Views: 619
Reputation: 343
Solved. Here's the line I needed:
jQuery( "input[name='addon-520-language-0[]'][value='spanish']" ).prop('checked',true);
Upvotes: 1