All pastes #188883 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-10-02 16:35 UTC
rendered paste body
function get_table(id)
{
	var table = document.createElement('table')
	table.id = id

	var query = '?add_row=True'
	var xmlHttp = get_xmlHttp()

	xmlHttp.open('GET', query, false)
	xmlHttp.send(null)

	var header_row = table.insertRow(0)
	var first_row = table.insertRow(1)
	var columns = xmlHttp.responseXML.getElementsByTagName('col')

	for (i = 0; i < columns.length; i++) {
		var col = columns[i]
		var children = col.childNodes
		var col_head = document.createElement('th')
		var cell = document.createElement('td')

		col_head.innerHTML = col.getAttribute('name')
		header_row.appendChild(col_head)

		for (j = 0; j < children.length; j++) {
			cell.appendChild(children[j])
		}

		first_row.appendChild(cell)
	}

	return table
}