Dynamically add extra input fields to Editor modal window

Dynamically add extra input fields to Editor modal window

nigel pasconigel pasco Posts: 37Questions: 6Answers: 0

Hi, just throwing out a general query of the form... can this be done? I am not sure if or how to go about this one.

Maybe best expalined by an example:
I have a datatables showing persons and the company they belong to from the table 'persons'. Clicking the 'New' Editor opens the form (modal) to input user name and select company from another table 'companies'. However, what if the required company is not in the list? I would like to include an 'add new company' option to the company drop-down list, which on-click will dynamically raise another input text field (or possibly another form in another modal window) to add a new company name to the 'company' table before submitting the intial form.

This is easily do-able with a standard ajax call in php, however I can't get my head around how it could be done with datatables.

Any thoughts people?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Yes - the add() method can be used to add fields dynamically. Likewise clear() can be used to remove them. show() and hide() may also be of some interest.

    Allan

  • nigel pasconigel pasco Posts: 37Questions: 6Answers: 0

    Well, there I go. I should have guessed that it would be so simple :P

    Thanks for the info Allan.
    nige

This discussion has been closed.