xuexue 15 Junior Poster

hi guys, i have this program wherein the user can add freely how many textboxes he want. now my problem is that i have a class on my first textbox which is

class= "TextBox"

then, i want to add that class name to the textbox added by the user..how could i code it??

this is my code for adding a new textbox

var table = document.getElementById(tableID); 
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);  
	
var cella = row.insertCell(0);
cella.style.backgroundColor = "EAEAEA";
var element1 = document.createElement("input");
element1.type = "text";
element1.name = "txtManufacturer[]";
element1.size = "7";
cella.appendChild(element1);

see attached picture..
the 1st textbox has a class="TextBox", now the 2nd box is dynamically generated by the user thru javascript, what i want to know is how could i code that one using javascript? ive tried

element1.className = "TextBox"

but this one does not work.

please help me..thanks in advacne..^^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.