How to show two different data tables on dropdown change

How to show two different data tables on dropdown change

pravspravs Posts: 29Questions: 4Answers: 0

I want to show two different data tables on change of the value in drop down,I want to show the two different data tables... Please help me i need it urgent

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    How far have you got?

  • crwdzrcrwdzr Posts: 31Questions: 5Answers: 6
    edited September 2017

    this is the basics of how i would go about doing it

    <select id="tableSelect">
        <option value="table1" selected>table 1</option>
        <option value="table2">table 2</option>
    </select>
    <div id="tables">
        <div id="table1">
            <!-- datatable goes here -->
        </div>
        <div id="table2" hidden>
            <!-- datatable2 goes here -->
        </div>
    </div>
    
    $('#tableSelect').on('change',function(){
        let table = $(this).val()
        $('#tables>div').fadeOut(100,function(){
            $('#'+table).show()
        })
    })
    

    initialize each datatable like you normally would, completely seperate from eachother. optionally you can make it so that it only initializes it when needed, how you do that is up to you

This discussion has been closed.