javascript - How to create checkbox column in the table? -


I am dynamically creating tables using javascript code:

  function CreatTable (Data) {bara tablerea; Var table; Wind var tr; Var th; Tablerea = document. GetElementById ('ShowDataID'); Table = document. CreateElement ('table'); Thead = document.createElement ('thead'); Tr = document.createElement ('tr'); (Var i = 0; i & lt; data; length; i ++) for {var headerTxt = document.createTextNode (data [i]); Th = document.createElement ('th'); Th.appendChild (headerTxt); Tr.appendChild (th); Thead.appendChild (tr); } Table.appendChild (thead); For (var i = 1; i <4; i ++) {tr = document.createElement ('tr'); Tr.appendChild (document.createElement ('TD')); Tr.appendChild (document.createElement ('TD')); Tr.appendChild (document.createElement ('TD')); Tr.cells [0] .appendChild (document.createTextNode ('John')); Tr.cells [1] .appendChild (document.createTextNode ('McDowell')); Tr.cells [2] .appendChild (document.createTextNode (willdd@gmail.com ')); Table.appendChild (tr); } Tablearea.appendChild (table); } & Lt; / Script & gt;  

When I create a table, I also need to make the checkbox column in the table above.

Any ideas how can I use this javascript? Or related links?

I'm not sure this is what you are asking:

  var checkbox = document. CreateElement ("INPUT"); Checkboxes. Type = "checkbox";  

And then you add the checkbox in each row to create a new column.

View this Bela: I've added comments

(Is this a duplicate?)


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -