Home › Forums › Quform WordPress › Looking for the right hook to trigger SQL query
- This topic has 5 replies, 3 voices, and was last updated 2 years, 10 months ago by csimstewart.
- AuthorPosts
- January 14, 2022 at 2:32 pm #33881csimstewartParticipant
I’ve written a PHP function which will perform a lookup in a custom table and pull in additional values to populate a Quform dropdown. I want this function called after the user enters input into a certain field. The function is currently set up with a static value for testing and is functioning properly using the
add_action('quform_pre_display_1', 'my_form_values');
However, this only works with my static testing value as this hook launches before any input from user. What hook can I set to send the value and trigger my function after the input for that part of the form is entered?
Basically the user picks a product and I lookup the current pricing options and return it on the next section of the form.
$product = $form->getValue('quform_1_10');
this $product will be used in the WHERE statement of the sql query.
Thanks for any help in advance!
January 15, 2022 at 12:59 am #33882oivanrParticipantHi,
This must be done through a js function calling php.
I suggest to read this subject: php call through ajax
Regards,January 17, 2022 at 8:38 am #33887AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 19, 2022 at 2:26 pm #33904csimstewartParticipantThank you @Ally and @oivanr. Both of those suggestions helped me get everything working from that initial issue question. I have a follow up question that I cannot find an answer for anywhere. Is there a jquery constructor similar to:
options.push (new Option(value, value));
which then:
$element.html(options).prop('selectedIndex', 0);
but will work on populating the options for a checkbox element in QuForm rather then the example of a dropdown? Or will I have to code all of the html variables as .append and generate the structure myself to push into the .html()?
Thank you both for your help!January 20, 2022 at 8:13 am #33907AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 26, 2022 at 9:03 pm #33950csimstewartParticipantThank you very much. Those posts contained the code hints I needed to get started solving each of my issues.
- AuthorPosts
- You must be logged in to reply to this topic.