I have one div id="container" container and I need to add labels to that div ( 10 or 4 or one - depends which button I click ) and need to look like table ( rows x 2 column ). How to achieve this ? How to add labels programmatically ?
A view that displays one or more lines of informational text.
You can use dojo.create function. E.g.:
var label = dojo.create("label", {for:"fieldId", innerHTML:"SomeText"}, "tableCellId");
where tableCellId - id of the element in which you want to append label
Similarly you can dynamically create a table, and add labels to a new table.
var table = dojo.create("table", null, dojo.body());
var row = dojo.create("tr", null, table);
var cell = dojo.create("td", null, row);
var label = dojo.create("label", {for:"fieldId", innerHTML:"SomeText"}, cell);
Dojo create documentation
Here's how I've been doing it in dojo.
dojo.place('<label for="field">Field Name</label>', dojo.byId('widget_fieldId'), 'before');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With