Skip Navigation

[Resolved] help for radio value check and jquery

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Waqar 8 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2638317

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

#2638513

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#2638603

In fact with toolsrt form the radio inout field are

  • and I don't see when it's checked
    How can I see that ?
  • #2639277

    Waqar
    Supporter

    Languages: English (English )

    Timezone: Asia/Karachi (GMT+05:00)

    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?

    #2639645

    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,

    #2640161

    Waqar
    Supporter

    Languages: English (English )

    Timezone: Asia/Karachi (GMT+05:00)

    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');
    		}
    	});
    });
    
    
    #2640887

    Hi Waqar,

    thanks for your answer !!!

    have a nice day !

    This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.