I have created a CRED form for a CPT with Radio fields but I would like to modify the value of an input text in jquery according to the radio that is checke how do I do it?
Here's the url: hidden link
In fact, I'll have to do it for all radios, but if I have an example I'll adapt it for the others.
Basically:
For the radio: "DRIVER Certification ENEC" if radio no is selected then this should assign 0 to the input "Note DRIVER Certification ENEC" otherwise if it's yes then it's 3 that should be assigned.
I've started to make a javascript/jquery script on the other inputs, but I can't see a solution for the radios.
Here is an example of the script that you can use for this case:
jQuery( document ).on( 'ready', function( event, data ) {
// detect change in the radio field 'wpcf-driver-certification-enec'
jQuery('input[type=radio][name=wpcf-driver-certification-enec]').change(function() {
// if value is '0' with label 'Non'
if (this.value == '0') {
// set text field 'wpcf-note-driver-certification-enec' value to '0'
jQuery('input[type=text][name=wpcf-note-driver-certification-enec]').val('0');
}
// if value is '1' with label 'Oui'
else if (this.value == '1') {
// set text field 'wpcf-note-driver-certification-enec' value to '3'
jQuery('input[type=text][name=wpcf-note-driver-certification-enec]').val('3');
}
});
});