Datatables a contact form

Datatables a contact form

Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

Hi,
I was just wondering if we can use DataTables a normal contact form? where each individual fills the form and data gets saved to database and then we can directly retrieve it from db?

I am supposed to send out form to costumers to fill out some financial information. They should be able to fill the form and on pressing submit button it gets directly saved to database where I can retrieve all the submitted data together?

Your help is highly appreciated

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,268Questions: 26Answers: 4,765

    Datatables is a plugin to format na HTML table. Using forms and posting them to a database is a separate function. Datatables can be used to display the database but you will need to create the client / server process to display and submit the form and on the server retrieve the data and insert into the DB. Maybe this article will help.

    Kevin

  • kthorngrenkthorngren Posts: 20,268Questions: 26Answers: 4,765

    If you are using the Editor you could create a form then use the create() to create new rows in the database.

    Kevin

  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

    @kthorngren

    Thank you. I am using the Editor and I was successfully able to create a form by using create() . The end user can create a new record and which gets saved in the database successfully. However, is it possible to send the form link separately without end user able to see the datatable.

    What I am trying to say is, the end user should access just the form with no privileges to see the datatable? and get the confirmation once the form data is submitted?

    I am sorry if I am asking basic questions as I am pretty new to this.

  • kthorngrenkthorngren Posts: 20,268Questions: 26Answers: 4,765

    See if this Standalone Editor example helps.

    Kevin

  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

    @kthorngren Thank you.
    I am sorry if I didn't explain it properly.

    I am trying to make each user to insert or update just one row in datatable. So If I have 5 users , each user should have one row associated with them. Also, user should only see the row which he created or updated.

    Is it possible?

    I can possibly make a form and process it with java-script and PHP. Save data in database and then read that table using Datatbles plugin.

    I was just wondering if there is an easy way round in editor ?

  • kthorngrenkthorngren Posts: 20,268Questions: 26Answers: 4,765

    re you wanting to show the associated row in a Datatable? If so, one option is to use -option ajax.data to pass a search parameter that can be used to filter the returned rows to the associated row.

    Otherwise if you are only wanting to fetch the associated data for the form then use a jQuery Ajax request to fetch the data.

    The Editor doesn't fetch the table data, thats what Datatables does.

    Kevin

  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

    @kthorngren Thank you

    Yes, I want to only display the data row in the table data which has been create by the user using create(). So that after the user submits the data, they can still see the data which has been submitted and edit it if needed.

    As you mentioned earlier, I know I need to use something like this in the datatable and pass the search parameter but I am not sure what parameter should I pass , so the ajax only returns the newly created data rows.

    $('#example').dataTable( {
      "ajax": {
        "url": "url here",
        "data": function ( d ) {
            d.extra_search = $('#extra').val();
        }
      }
    
  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

    @kthorngren
    I just need a suggestion please.
    As DataTables is mostly for data display.
    Do you think it will be good idea if I made a MySQL JQuery PHP based form to populate database and then display data using Datatbles?
    Thank you
    Your help is highly appreciated

  • allanallan Posts: 61,644Questions: 1Answers: 10,093 Site admin
    Answer ✓

    This plug-in can be of use here. Use it inside Editor's submitComplete event handler (at that point the table has redrawn, and the parameters passed into the event handler will give you the data that was added, so you can jump to that point).

    Allan

This discussion has been closed.