Two select boxes : the first one control the ipopts of the second

Two select boxes : the first one control the ipopts of the second

AlexandreDelachapelleAlexandreDelachapelle Posts: 9Questions: 3Answers: 0

Hi everybody,

My config :
- DataTables 1.10.4
- Editor 1.3.3
- TableTools 2.2.3

I am using two select boxes : "city" and "postcode".
I want that the ipOpts-Fields of my second select box change depending on selecting a value in the first select box.
I found a solution here : http://www.datatables.net/forums/discussion/13925/two-select-boxes-can-first-select-box-control-the-ipopts-of-the-second
But I don't understand this solution... So if someone understand, could you briefly explain me how to implement it ?
Thanks for your help !
Here is my code :

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {   
    editor = new $.fn.dataTable.Editor( {
        ajax: "../php/todo.php",
        table: "#example",
        fields: [ {
                label: "Lastname:",
                name: "last_name"
            }, {
                label: "City:",
                name: "city",
                type: "select", 
                ipOpts: [
                    { label: "Paris", value: "Paris" },
                    { label: "London", value: "London" }
                ]
            }, {
                label: "Postcode:",
                name: "postcode",
                type: "select",
                ipOpts: [
                    { label: " A", value: " A" },   /* Paris */
                    { label: " B", value: " B" },   /* Paris */
                    { label: " C", value: " C" },   /* Paris */
                    { label: " 1", value: " 1" },   /* London */
                    { label: " 2", value: " 2" },   /* London */
                    { label: " 3", value: " 3" }    /* London */
                ]
            }
        ]
    } );

    $('#example').DataTable( {             
        dom: "Tfrtip", 
        ajax: "../php/todo.php",
        columns: [
            { data: "last_name" },
            { data: "city" },
            { data: "postcode" }
        ],
        tableTools: {
            sRowSelect: "os",
            aButtons: [
                { sExtends: "editor_create", sButtonClass: "save-collection", editor: editor }, /* id:I6 */
                { sExtends: "editor_edit",   editor: editor },
                { sExtends: "editor_remove", editor: editor },
            ]
        }
    } );
} );

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.