Two tables with same ID on same page

Two tables with same ID on same page

aseemaseem Posts: 1Questions: 0Answers: 0
edited January 2014 in General
I am using nested TMPL_LOOP to generate multiple tables , so basically all of them has same id (proctable_head)
I am using dataTable for scrolling in these tables
But due to same id it only initializes the first table.
is there a way to use it for multiple tables?

[code]




























[/code]

I am initializing the dataTable as
[code]
$(document).ready(function () {
var tab = $('#proctable_head').dataTable( {
"sScrollY": 430,
"sScrollX": 410,
"bLengthChange": false,
"bPaginate": false,
"bInfo": false,
"bSort": false,
"bStateSave": true,
"bScrollCollapse": true,
"bAutoWidth": false,
"bFilter": false
} );
});


[/code]

Replies

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    edited March 2015
    > But due to same id it only initializes the first table. is there a way to use it for multiple tables?

    No - an id must be unique in HTML. To have two identical ids is invalid HTML.

    Multiple tables can be initialised by selecting them correctly with a single jQuery selector expression - [for example](/examples/basic_init/multiple_tables.html).

    Allan
This discussion has been closed.