Skip Navigation

[Resolved] Automatically delete a field value when another field is changed

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 13 replies, has 2 voices.

Last updated by salimA 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1985433

Hi

I have used the below code to change the status to pending when the Organization changed

jQuery(document).on('cred_form_ready', function(){
jQuery( 'select[name="wpcf-org"]' ).change(function() {
jQuery( 'b.wpcf-request-status' ).text('Pending');
jQuery( 'input[name="wpcf-request-status"][value=3]' ).prop("checked",true);
});
});

Now I would like to update the code to empty/delete the rejection-reason field value( the field type is text), also when the Organization changed.

what I did is

jQuery(document).on('cred_form_ready', function(){
jQuery( 'select[name="wpcf-org"]' ).change(function() {
jQuery( 'b.wpcf-request-status' ).text('Pending');
jQuery( 'input[name="wpcf-request-status"][value=3]' ).prop("checked",true);
jQuery('input[name="wpcf-rejection-reason"]').val('');
});
});

the status changed but the rejection reason not deleted. What is the wrong on jQuery('input[name="wpcf-rejection-reason"]').val('');

#1985719

Hello, I don't see anything obviously wrong in this code. For a standard single line text field, it should be possible to manipulate the value with jQuery.val(). If the input field is emptied after changing the Organization field, then the empty value should be saved correctly for the rejection reason field when the Form is submitted. If the field is not emptied when the Organization field is changed, then there must be something else going on. Is it possible there is some other custom code interfering in this process, or a caching system holding on to old field values? Perhaps you can try disabling all custom code snippets and all 3rd-party plugins, and activate a default theme like Twenty Twenty One. Then add your custom JS and test again. If the problem is resolved, then you know there is some conflict with another component. Reactivate your other custom code snippets and third-party plugins one by one, testing each time, until the problem returns.

#1989957

Hi Christian,

thank you for your reply.
I did what you suggested but unfortunately, the text field still not emptied after changing the Organization field.

#1990729

Maybe the issue is in the jQuery name selector for some reason. Can I see the Form on the front-end of your site? Please provide a URL.

#1991225
2.JPG
1.JPG

Please check the attached image.

#1991267
2.JPG
1.JPG

Please check the attached

#1992563

Thank you, I see your Forms screenshots but unfortunately they do not reveal anything obviously wrong in the JavaScript code snippet. I need to check this Form in the browser to understand why it is not working. This will allow me to use the browser's JavaScript debugging tools to figure out the problem. Please provide a URL where I can see the Form on your live site, or a URL to see the Form on a development testing site if you want me to help troubleshoot the custom code. All URLs you share in the forum are hidden from public view for your privacy and security.

I have activated private reply fields here so you can share a login if necessary. Thank you!

#1995651

Please try to add the IP in the host file. I have updated the private reply to add the Host IP.

#1996125

Unfortunately I am still unable to access the login with this IP and domain in my hosts file. I asked another supporter to test the login information as well. Shane added the IP to his host file and tested the login URL, but he had the same results. Neither of us can load the site, we get server timeout errors.

If it's too much trouble, we can try exporting your Types and Forms information using Toolset's Export tool, then try importing those structures in a sandbox site. If the problem is reproducible in a sandbox site, I will be able to investigate there.

Would you like to share your exported Types and Forms information instead?

#1997167

Hi Christian,

I have export Forms, views, and Types. All are on this link. hidden link

I could share a copy of the website using the Duplicator plugin if needed.

#1997757

Okay yes, I believe I need the Duplicator clone. I created a sandbox site and imported the Types and Forms content you shared. I placed the Update User Form on a new Page and tested it. I added some example text in the Rejection Reason field, then changed the "Please Register with other Organization" select field. As soon as I changed the select field, the contents of the Rejection Reason field were deleted. I made a screen recording for you:
https://drive.google.com/file/d/1j4xPdgcxh79ZYjHHC5ZbReGoG6JG07aO/view?usp=sharing

Something else must be going on, and I will need a site clone to be able to troubleshoot the problem. Please provide a download link here so I can access the Duplicator clone. Also, please let me know where to find the Update User Form on the front-end of the site. If I must follow some specific steps to access the Form, please provide step-by-step instructions.

#1998743

Website copy on this link: hidden link

Kindly take all required details from the Previous private reply.

#1999475

Thank you, I was able to download and install the site clone. When I log in as the User "test", I am able to test the Form at /sarh-profile. When I change the Organization field, the Rejection Reason field is cleared automatically. Have I misunderstood the problem? I have uploaded a screen recording here: https://drive.google.com/file/d/1YogQucLJcB7JFXFkfm_yaL3sVFbSJENf/view?usp=sharing

You can see the behavior is as described. The Rejection Reason field contents are cleared any time I change the select field. Am I missing something?

#2000193

Strange!!! It is working with me now also. I don't know what is magic happened. I spent more than 2 weeks investigating the issue.

Many Thanks, Christian for your efforts.