0

Is there a way to simply have a form in a page that the user can fill in and on submit continually populate a table directly underneath the the submit button.

This information must also be saved/stored so that when the user comes back the previous posts are there

Im not sure I know how to do what was explained.

This is my form, works fine

<form id="myForm" action="" method="post" target="_parent">

<p>Date: 
<input type="date" cf_name="Date" value="" maxlength="25" size="60">


Weight:
<input type="text" cf_name="Weight" value="" maxlength="25" size="60">
</p>

<p>Comments:
<input type="text" cf_name="comments" value="" maxlength="200" size="60">
</p>

<p>Insert Picture (optional):
<input type="text" cf_name="pic1" value="" maxlength="200" size="60">
</p>


<p> 
<input id="submit" type="button" value="Submit" cf_name="submit">
<input type="button" cf_name="cancel" value="Cancel" onClick="closebox()">
</p>
</form>

<table id="details"></table>
1

You can have an ajax action that sent the data to the backend populate the table and return the success or the errors back.

You can use this actions

add_action('wp_ajax_*', 'custom_table_insert');
add_action('wp_ajax_nopriv_*', 'custom_table_insert'); // anonymous users

This will give you more control and ultimately a far better user experience. // Ajax Request template

jQuery.ajax({
        url : your_settings_object.ajax_url,
        type : 'post',
        data : {
            action : 'wp_ajax_*',
            table_content : table_content
        },
        success : function( response ) {
            alert(response)
        }
    });

Note: your_settings_object is a custom object that use to transfer global variables from backend to JS Also the table_content is your variable to pass the data and you can take them from the PHP with $_POST['table_content']

  • Thanks but i'm a noobe at this wp stuff. this is my form so how do I get it done with what you wrote. I was looking for something simple! – dealer58 Nov 4 '17 at 18:53
0

Ask the googles about 'how to post to the same page'. Using that information, you will test for a the posting action and then populate the form fields with the posted information.

But with WP, you will also need to create a custom template to do this action. (With a non-WP site, you would just need the code for that page.) You'll need to understand Custom Templates; there are many tutorials about that, one is here http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/ ).

A bit of research will help you figure this out. There is not a simple process; but it is an enjoyable learning experience for this geek.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.