001.
function
getCustomBoardRows(i, type){
002.
003.
return
'<u><b>บอร์ดที่ '
+i+
'</b></u> จำนวนบอร์ด <INPUT TYPE="TEXT" SIZE="3" NAME="txtBoardSize_'
+i+
'" ID="txtBoardSize_'
+i+
'" class="inputtext_nfixw" VALUE=""> ชนิดของบอร์ด <INPUT TYPE="TEXT" SIZE="15" NAME="txtBoardType_'
+i+
'" ID="txtBoardType_'
+i+
'" class="inputtext_nfixw" VALUE=""> หมายเหตุ <INPUT TYPE="TEXT" SIZE="45" NAME="txtBoardType_'
+i+
'" ID="txtBoardType_'
+i+
'" class="inputtext_nfixw" VALUE=""> <input name="btnAdd[]" type="button" id="btnAdd_ItemBoardStandard" class="button" value="+Add item" onClick="CreateNewItem(\''
+type+
'\',\''
+i+
'\')">'
;
004.
}
005.
006.
function
getStandBoardRows(i, type){
007.
008.
return
'<u><b>บอร์ดที่ '
+i+
'</b></u> จำนวนบอร์ด <INPUT TYPE="TEXT" SIZE="3" NAME="txtBoardSize_'
+i+
'" ID="txtBoardSize_'
+i+
'" class="inputtext_nfixw" VALUE=""> ชนิดของบอร์ด <INPUT TYPE="TEXT" SIZE="15" NAME="txtBoardType_'
+i+
'" ID="txtBoardType_'
+i+
'" class="inputtext_nfixw" VALUE=""> หมายเหตุ <INPUT TYPE="TEXT" SIZE="45" NAME="txtBoardType_'
+i+
'" ID="txtBoardType_'
+i+
'" class="inputtext_nfixw" VALUE=""> <input name="btnAdd[]" type="button" id="btnAdd_ItemBoardStandard" class="button" value="+Add item" onClick="CreateNewItem(\''
+type+
'\',\''
+i+
'\')">'
;
009.
}
010.
011.
function
getHeadColumn(type){
012.
var
customHead =
new
Array(
"ชื่อกระเบื้อง"
,
"ขนาด"
,
"จำนวน"
,
"หน่วย"
,
"ประเภทแผ่น"
,
"ขนาดแผ่นตัด"
,
"ราคา/หน่วย"
,
"ราคารวม"
,
"หมายเหตุ"
,
""
);
013.
var
standHead =
new
Array(
"หมายเลขบอร์ด"
,
"ชื่อบอร์ด"
,
"ประเภทบอร์ด"
,
"จำนวนบอร์ด"
,
"จำนวนบอร์ด"
,
"หมายเหตุ"
,
""
);
014.
return
(type ==
"btn_board"
)? customHead : standHead;
015.
}
016.
017.
function
CreateNewBoard(typeBoard){
018.
var
typeBoard = typeBoard.id
019.
var
field = getHeadColumn(typeBoard);
020.
var
allColumn = (typeBoard==
"btn_board"
)? 10:7;
021.
intBoard = parseInt(document.frm_request.hdnMaxBoard.value);
022.
intBoard++;
023.
alert(intBoard);
024.
025.
########################## บรรทัดนี้เราต้อง Fix ค่าตาราง หมายเลขตารางป่าวคะ ###############################
026.
########################## แต่เราไม่รู้ว่า ตรงฟอร์ม HTML เราจะให้เลขไปต่อท้ายหลังยังไงนะคะเช่น tblBoard_1 tblBoard_2 อย่างนี้นะคะ ######
027.
var
tableBoard = (typeBoard==
"btn_board"
)? document.getElementById(
"tblBoard"
) : document.getElementById(
"tbl_boardstandard"
);
028.
029.
030.
for
(intRow=0;intRow<2;intRow++){
031.
if
(intRow==0){
032.
var
insertRow1 = tableBoard.insertRow(0);
033.
var
Row1Cell1 = insertRow1.insertCell(0);
034.
Row1Cell1.colSpan = allColumn;
035.
Row1Cell1.style.backgroundColor =
"#A7C520"
;
036.
Row1Cell1.style.color =
"black"
;
037.
Row1Cell1.innerHTML = (typeBoard==
"btn_board"
)? getCustomBoardRows(intBoard, typeBoard) : getStandBoardRows(intBoard, typeBoard);
038.
}
else
{
039.
var
insertRow2 = tableBoard.insertRow(intRow);
040.
for
(intCol=0;intCol<allColumn;intCol++){
041.
var
Row2Cell = insertRow2.insertCell(intCol);
042.
Row2Cell.style.backgroundColor =
"#F5F6D4"
;
043.
Row2Cell.innerHTML=
"<center>"
+field[intCol]+
"</center>"
;
044.
}
045.
}
046.
}
047.
CreateNewItem(typeBoard);
048.
document.frm_request.hdnMaxBoard.value = intBoard;
049.
}
050.
051.
function
CreateNewItem(type,board){
052.
alert(board);
053.
var
intLine = parseInt(document.frm_request.hdnMaxLine1.value);
054.
intLine++;
055.
var
theTableBoard = (type==
"btn_board"
)? document.getElementById(
"tblBoard"
) : document.getElementById(
"tbl_boardstandard"
);
056.
var
insertRow = theTableBoard.insertRow(2);
057.
var
intField = (type==
"btn_board"
)? 10:7;
058.
for
(
var
ii=0;ii<intField;ii++){
059.
eval(
"var RowCell"
+(ii+1)+
" = insertRow.insertCell("
+ii+
");"
);
060.
}
061.
if
(type==
"btn_board"
){
062.
063.
RowCell1.innerHTML =
"<center>"
+intLine+
" <SELECT NAME=\"txtProductName_"
+intLine+
"\" ID=\"txtProductName_"
+intLine+
"\" class=\"inputtext_nfixw\" OnChange=\"JavaScript:doCallAjax('txtProductName_"
+intLine+
"','txtProductID_"
+intLine+
"','txtBaseUnit_"
+intLine+
"','txtPricePerUnit_"
+intLine+
"');\"></SELECT></center>"
;
064.
065.
CreateSelectOption(
"txtProductName_"
+intLine,
"productTiles"
+intLine,intLine)
066.
067.
RowCell2.innerHTML =
"<center>"
+intLine+
" <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"txtProductID_"
+intLine+
"\" ID=\"txtProductID_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"><INPUT TYPE=\"TEXT\" SIZE=\"4\" NAME=\"txtBaseUnit_"
+intLine+
"\" ID=\"txtBaseUnit_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"><INPUT TYPE=\"TEXT\" SIZE=\"4\" NAME=\"txtPricePerUnit_"
+intLine+
"\" ID=\"txtPricePerUnit_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
068.
069.
RowCell3.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizewidth_"
+intLine+
"\" ID=\"sizewidth_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"> X <INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizelength_"
+intLine+
"\" ID=\"sizelength_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
070.
071.
RowCell4.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"2\" NAME=\"quantity_"
+intLine+
"\" ID=\"quantity_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
072.
073.
RowCell5.innerHTML =
"<center><SELECT NAME=\"unit_"
+intLine+
"\" ID=\"unit_"
+intLine+
"\" class=\"inputtext_nfixw\" OnChange=\"JavaScript: doCalPrice('txtProductID_"
+intLine+
"','quantity_"
+intLine+
"','unit_"
+intLine+
"','pricetotal_"
+intLine+
"');\"></SELECT></center>"
;
074.
075.
CreateSelectOption(
"unit_"
+intLine,
"unit_"
+intLine,intLine)
076.
077.
RowCell5.innerHTML =
"<center><SELECT NAME=\"typepcs_"
+intLine+
"\" ID=\"typepcs_"
+intLine+
"\" class=\"inputtext_nfixw\" ></SELECT></center>"
;
078.
079.
CreateSelectOption(
"typepcs_"
+intLine,
"typepcs_"
+intLine,intLine)
080.
081.
RowCell6.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizewidth_subpcs_"
+intLine+
"\" ID=\"sizewidth_subpcs_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"> X <INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizelength_subpcs_"
+intLine+
"\" ID=\"sizelength_subpcs_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
082.
083.
RowCell7.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"priceperunit_"
+intLine+
"\" ID=\"priceperunit_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
084.
085.
RowCell8.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"pricetotal_"
+intLine+
"\" ID=\"pricetotal_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
086.
087.
RowCell9.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"15\" NAME=\"remark_"
+intLine+
"\" ID=\"remark_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
088.
089.
RowCell10.innerHTML =
"<center><input name=\"btnDel\" type=\"button\" id=\"btnDel\" value=\"-\" onClick=\"RemoveRow('row_"
+intLine+
"');\"></center>"
;
090.
091.
}
else
{
092.
093.
RowCell1.innerHTML =
"<center>"
+intLine+
" <SELECT NAME=\"txtProductName_"
+intLine+
"\" ID=\"txtProductName_"
+intLine+
"\" class=\"inputtext_nfixw\" OnChange=\"JavaScript:doCallAjax('txtProductName_"
+intLine+
"','txtProductID_"
+intLine+
"','txtBaseUnit_"
+intLine+
"','txtPricePerUnit_"
+intLine+
"');\"></SELECT></center>"
;
094.
095.
CreateSelectOption(
"txtProductName_"
+intLine,
"productTiles"
+intLine,intLine)
096.
097.
RowCell2.innerHTML =
"<center>"
+intLine+
" <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"txtProductID_"
+intLine+
"\" ID=\"txtProductID_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"><INPUT TYPE=\"TEXT\" SIZE=\"4\" NAME=\"txtBaseUnit_"
+intLine+
"\" ID=\"txtBaseUnit_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"><INPUT TYPE=\"TEXT\" SIZE=\"4\" NAME=\"txtPricePerUnit_"
+intLine+
"\" ID=\"txtPricePerUnit_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
098.
099.
RowCell3.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizewidth_"
+intLine+
"\" ID=\"sizewidth_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"> X <INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizelength_"
+intLine+
"\" ID=\"sizelength_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
100.
101.
RowCell4.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"2\" NAME=\"quantity_"
+intLine+
"\" ID=\"quantity_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
102.
103.
RowCell5.innerHTML =
"<center><SELECT NAME=\"unit_"
+intLine+
"\" ID=\"unit_"
+intLine+
"\" class=\"inputtext_nfixw\" OnChange=\"JavaScript: doCalPrice('txtProductID_"
+intLine+
"','quantity_"
+intLine+
"','unit_"
+intLine+
"','pricetotal_"
+intLine+
"');\"></SELECT></center>"
;
104.
105.
CreateSelectOption(
"unit_"
+intLine,
"unit_"
+intLine,intLine)
106.
107.
RowCell5.innerHTML =
"<center><SELECT NAME=\"typepcs_"
+intLine+
"\" ID=\"typepcs_"
+intLine+
"\" class=\"inputtext_nfixw\" ></SELECT></center>"
;
108.
109.
CreateSelectOption(
"typepcs_"
+intLine,
"typepcs_"
+intLine,intLine)
110.
111.
RowCell6.innerHTML =
"<center><INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizewidth_subpcs_"
+intLine+
"\" ID=\"sizewidth_subpcs_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"> X <INPUT TYPE=\"TEXT\" SIZE=\"1\" NAME=\"sizelength_subpcs_"
+intLine+
"\" ID=\"sizelength_subpcs_"
+intLine+
"\" class=\"inputtext_nfixw\" VALUE=\"\"></center>"
;
112.
113.
RowCell7.innerHTML =
"<center><input name=\"btnDel\" type=\"button\" id=\"btnDel\" value=\"-\" onClick=\"RemoveRow('row_"
+intLine+
"');\"></center>"
;
114.
}
115.
116.
document.frm_request.hdnMaxLine1.value = intLine;
117.
118.
}