Bananas Development Blog: share your thoughts

Neue Tabellenspalte hinzufügen.

Für manche ist es ein alter Hut aber für mich war es neu.
Mit Javascript kann man dynamisch Reihen oder sogar Spalten in eine Tabelle hinzufügen.

Hier mal mein Beispiel für das Hinzufügen einer neuen Reihe.

function addNewRow() {
	tableObj = document.getElementById('tableCol');
	// add new row at the end
	row = tableObj.insertRow(-1);

	var x=row.insertCell(0);
	x.innerHTML="cell1";

	var z=row.insertCell(1)
	z.innerHTML="cell2";
}


Diese Funktion legt an der tabelle mit der ID "tableCol" eine Neue Reihe am Ende ( das -1 bei .insertRow ) an.
Dies kann beliebig oft wiederholt werden.

Quellen:
JavaScript HTML DOM Examples
Delete rows in a table
Add rows to a table
  • No comments

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Trackbacks / Pingbacks

  • No Trackbacks