function fnInputCreate(tbodyId, pnum,limitCount, pnumSize,pnumColor) {
var myTbody = document.getElementById(tbodyId);
//alert(tbodyId);
var row = document.createElement("tr");
var rowId = "row" + rowCnt++;
var cell = document.createElement("td");
var cell2 = document.createElement("td");
var cell3 = document.createElement("td");
var cell4 = document.createElement("td");
var cell5 = document.createElement("td");
var i_idx = document.createElement("input"); //-- o_idx
var i_pnum = document.createElement("input"); //-- o_num
var i_countchk = document.createElement("input"); //-- o_countcheck
var i_size = document.createElement("select"); //-- o_size
var i_color = document.createElement("select"); //-- o_color
var i_count = document.createElement("input"); //-- o_count
row.setAttribute("style","text-align:center;")
i_idx.setAttribute("type", "hidden");
i_idx.setAttribute("name", "o_idx[]");
i_idx.setAttribute("value", "");
i_pnum.setAttribute("type", "hidden");
i_pnum.setAttribute("name", "o_num[]");
i_pnum.setAttribute("value", pnum);
i_countchk.setAttribute("type", "hidden");
i_countchk.setAttribute("name", "o_countcheck[]");
i_countchk.setAttribute("value", limitCount);
i_size.setAttribute("name", "o_size[]");
i_size.setAttribute("value", "M");
i_size.setAttribute("style", "width:60px;");
//--- Size Option first
if (isIE()) {
i_size.options[0] = new Option("Size", "");
}
else {
i_sizeop = document.createElement("option"); //-- o_size - option
i_sizeop.appendChild(document.createTextNode("Size"));
i_sizeop.setAttribute("value", "");
i_size.options.add(i_sizeop);
}
for (var i = 0; i < pnumSize.length; i++){
ii = i +1;
if (isIE()) {
i_size.options[ii] = new Option(pnumSize[i], pnumSize[i]);
}else{
i_sizeop = document.createElement("option"); //-- o_size - option
i_sizeop.appendChild(document.createTextNode(pnumSize[i]));
i_sizeop.setAttribute("value", pnumSize[i]);
i_size.options.add(i_sizeop);
}
};
i_color.setAttribute("name", "o_color[]");
i_color.setAttribute("value", "1");
i_color.setAttribute("style", "width:100px;");
//--- Color Option First
if (isIE()) {
i_color.options[0] = new Option("Color", "");
}else{
i_colorop = document.createElement("option"); //-- o_color - option
i_colorop.appendChild(document.createTextNode("Color"));
i_colorop.setAttribute("value", "");
i_color.options.add(i_colorop);
}
for (var i = 0; i < pnumColor.length; i++){
ii = i + 1;
if (isIE()) {
i_color.options[ii] = new Option(colorchip_name(pnumColor[i]), pnumColor[i]);
}else{
i_colorop = document.createElement("option"); //-- o_size - option
//i_colorop.appendChild(document.createTextNode(pnumColor[i]));
i_colorop.appendChild(document.createTextNode(colorchip_name(pnumColor[i])));
i_colorop.setAttribute("value", pnumColor[i]);
i_color.options.add(i_colorop);
}
};
i_count.setAttribute("type", "text");
i_count.setAttribute("name", "o_count[]");
i_count.setAttribute("value", limitCount);
i_count.setAttribute("style", "ime-mode:disabled;width:50px;text-align:right;");
var button = document.createElement("input");
var button2 = document.createElement("input");
if (isIE()) {
row.id = rowId;
button = document.createElement("<input onclick=\"fnInputCreate('" + tbodyId + "','" + pnum + "','" + limitCount + "', size_" + pnum + ", color_" + pnum + ")\" />");
button2 = document.createElement("<input onclick=\"fnInputRemove('" + rowId + "')\" />");
} else {
row.setAttribute("id", rowId);
button.setAttribute("onclick", "fnInputCreate('" + tbodyId + "','" + pnum + "','" + limitCount + "', size_" + pnum + ", color_" + pnum + ")");
button2.setAttribute("onclick", "fnInputRemove('" + rowId + "')");
}
button.setAttribute("type", "button");
button.setAttribute("value", "+");
button.setAttribute("class", "newButton");
button.setAttribute("style", "width:25px;");
button2.setAttribute("type", "button");
button2.setAttribute("value", "-");
button2.setAttribute("class", "newButton");
button2.setAttribute("style", "width:25px;");
cell.appendChild(i_idx);
cell.appendChild(i_pnum);
cell.appendChild(i_countchk);
cell.appendChild(i_size);
cell2.appendChild(i_color);
cell3.appendChild(i_count);
cell4.appendChild(button);
cell5.appendChild(button2);
row.appendChild(cell);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell4);
row.appendChild(cell5);
myTbody.appendChild(row);
}
function delEventPresentRow(buttonObj) {
var tableBody = document.getElementById("targetBody");
var index = buttonObj.parentElement.parentElement.rowIndex;
tableBody.removeChild(tableBody.childNodes[index]);
}
function fnInputRemove(rowId) {
var row = document.getElementById(rowId);
//alert(rowId);
row.parentNode.removeChild(row);
}
Posted by 홍반장