WordPress.org

Ready to get started?Download WordPress

Forums

Need jquery/ajax help for form fields (2 posts)

  1. Kacomp
    Member
    Posted 11 months ago #

    Hi there,
    I am writing a plugin to extend an existing plugin called appointments+
    You use it to book appointments eg, hairdresser. I am extending it so you can add extra fields in the booking form. The booking form using ajax. Now I can create new fields in the form but I just cant seem to get the value of the text input. I am using the following code to get the value
    var app_test_field = $(".appointments-test-field-entry").val();
    Now this works fine for a checkbox but not for text field. I feel I am missing something fundamental about how Ajax works. an anyone shed light on why this is failing?
    Thanks.
    Karen.

  2. bcworkz
    Member
    Posted 11 months ago #

    It depends on what you want to do with the entered values and how the appointments plugin handles form data. Typically all form elements are sent as an array, so if your added elements are inside the form tags there's a good chance the values are reaching the server.

    What happens at the server also depends on the appointments plugin. If it saves all values as a single array, your values will be stored as well. You just need to figure out how to access them. This is less likely, array values are often parsed out for separate handling, so you probably need to handle your portion of the data by hooking into the same ajax action (assuming the plugin is correctly using WP style AJAX) used by the plugin. var_dump($_POST); to see if your values are being sent and how to access them.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.