Skip Navigation

[Closed] Update the form field after an ajax call

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.

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 1 year, 10 months ago.

Author
Posts
#2526279
Screenshot 2023-01-03 at 9.42.12 PM.png

Dear Sir/Madam,

Referring to the screenshot, and I have a form and some button to call the update function via the ajax. I can able to update the field from the backend, but how can I also update the field value from the frontend instead of reloading the page?

Best regards,

Kelvin.

#2526843

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2023-01-04 at 07.44.17.png

You want to update a single field via ajax? Or submit the whole form via ajax?

Submitting the whole form via ajax is based on your form settings (screenshot).

There is no option to update an individual field via ajax, that would require a custom solution not based on Toolset Forms.

#2526891

I am not going to submit the form but only update a particular field and then update the display in form. I will do update_post_meta(), the value in field won’t be refreshed without reload the form but I want to update the display using javascript, I need to know how to get the element and change the display if I have the field wpcf-. Should I change the label or something?

#2527179

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm not sure if I understand what you are aiming for.

If this is a form with fields, then when someone enters a value in a field, then the field shows that value. There is nothing to update in the form itself, because it displays the value the user just entered. But at this stage the value is only in the form in the browser of the user; until the form is submitted the field value in the database doesn't get updated.

If you want to somehow have a user enter a value in a field in the form and then update the value of the field in the database without submitting the form, then that's not possible. (Well, you can create a custom solution that involves sending the value via ajax whenever the field input changes, and on the server responding to the ajax request and updating the field value with update_post_meta. But that isn't something dependent on Toolset, it is very much a custom solution.)

The topic ‘[Closed] Update the form field after an ajax call’ is closed to new replies.