I'm trying to add a table into an HTML page,using a js function.
I saw many examples for adding\removing data from an existing table,but can't find example of adding a new table that hadn't existed before.
I am having inside my javascript variables with all the information I need for the table,now I only need to find a way to do that...lets assume my var's are v1,v2,v3,v4 and i want to creat the following table:
v1 v2
v3 v4
what is the correct code that would execute the above?
wrapper.innerHTML = '<table><tr><td>' + v1 + '</td><td>' + v2 + '</td></tr><tr><td>' + v3 + '</td><td>' + v4 + '</td></tr></table>';wherewrapperis a reference to some DOM-element in which you want to put the table. If the number of rows/cells is not fixed, I recommend a function which creates the HTML string dynamically.