I am working on a custom widget that allows user to enter a field (Name). When the user clicks "Add Name", the widget should add another new field without refreshing the page and without saving the input.

In short, the form should be dynamic by allowing user to add new Name field with a click of a button. All the fields only save when the user clicks on the wordpress default "Save" button.

I found a widget that has the dynamic form, but it saves and updates the form automatically on every "Add Row" button pressed, which I don't want. Here is the link to that plugin: https://wordpress.org/plugins/repeater-entries-widget/screenshots/

Note: I know we can achieve this by using custom post type, but I think custom post type is not a good feed for my purpose.

  • I have successfully get it to work on custom post type, but I prefer just to have custom widget. Anyway, here is the code I've tried within the Form function. – Sengngy Kouch Feb 21 '17 at 18:53
  • <div id="here"></div> <input type="button" id="add" value="Click Me!" " /> <script> jQuery(document).ready(function(){ //call when the button is click $(document).on('click', '#add', function() { $('#here').append('<p>Hello</p>'); }); }); </script> – Sengngy Kouch Feb 21 '17 at 18:53
  • Some how, it doesn't show the Hello paragraph. And sorry for the bad format of the code. – Sengngy Kouch Feb 21 '17 at 18:55

Your Answer

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

Browse other questions tagged or ask your own question.