Hello,
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
thanks
Hi,
Thank you for contacting us and I'd be happy to assist.
You'll find some good examples of how 'change' event can be used for requirements such as this, in the following links:
https://stackoverflow.com/questions/13152927/how-to-use-radio-on-change-event
hidden link
I hope this helps and please let me know if you need further assistance.
regards,
Waqar
In fact with toolsrt form the radio inout field are
and I don't see when it's checked
How can I see that ?
I can guide you with the example code snippet, but I see multiple radio and text input fields in the form.
Can you please share more specific details about what you're trying to achieve?
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.
Thanks in advance,
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');
}
});
});
Hi Waqar,
thanks for your answer !!!
have a nice day !