Hi All,
I have been working on a script that takes the user input to a number of text fields and populates a table dynamically from that input. Everything is working great and all I want to do now is set the column widths of the table columns to something more in keeping with the character lengths that are being entered. I have tried a number of things but my table always has the same evenly sized columns. I have tried:
node.width=()
node.style.width=()
node.setAttribute()
I can’t seem to figure out which element the statement should act upon or exactly how to write the statement. Thanks in advance for any help.
Kind regards,
Ken
[CODE]
function addRow(tableID) {
if (!document.getElementById(tableID)) {
var body = document.getElementsByTagName(“fieldset”)[2];
var tbl = document.createElement(“table”);
var tblBody = document.createElement(“tbody”);
tbl.appendChild(tblBody);
body.appendChild(tbl);
tbl.setAttribute(“id”, “dataTable”);
tbl.setAttribute(“border”, “0”);
}
var StartTime = document.getElementById(‘StartTime’);
var EndTime = document.getElementById(‘EndTime’);
var MaterialID = document.getElementById(‘MaterialID’);
var Title = document.getElementById(‘Title’);
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement(“input”);
element1.type = “checkbox”;
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
var element2 = document.createElement(“input”);
element2.type = “text”;
element2.setAttribute(“name”,”StartTime[]”);
element2.setAttribute(“readonly”,”true”);
element2.value = StartTime.value;
cell2.appendChild(element2);
StartTime.value=””;
var cell3 = row.insertCell(2);
var element3 = document.createElement(“input”);
element3.type = “text”;
element3.setAttribute(“name”,”EndTime[]”);
element3.setAttribute(“readonly”,”true”);
element3.value = EndTime.value;
cell3.appendChild(element3);
EndTime.value=””;
var cell4 = row.insertCell(3);
var element4 = document.createElement(“input”);
element4.type = “text”;
element4.setAttribute(“name”,”MaterialID[]”);
element4.setAttribute(“readonly”,”true”);
element4.value = MaterialID.value;
cell4.appendChild(element4);
MaterialID.value=””;
var cell5 = row.insertCell(4);
var element5 = document.createElement(“input”);
element5.type = “text”;
element5.setAttribute(“name”,”Title[]”);
element5.setAttribute(“readonly”,”true”);
element5.value = Title.value;
cell5.appendChild(element5);
Title.value=””;
}