JSFiddle - React, Tailwind, and code Playground
HTML
<div>
1-批號:<input type="text" name="lot_1" size="10">、
有效日期:<input type="text" name="effect_date_1" size="10" value="" class="calendarSelectDate"><div id="calendarDiv"></div>
<input name="Check1" type="radio" value="No" />無。
<input name="Check1" type="radio" value="Yes" />有。
<input type="hidden" name="lot[]" value="1">
</div>
<span id="fieldSpace_2"></span>
<a href="javascript:" onclick="addField_2()">新增欄位</a>
<a href="javascript:" onclick="delField_2()">刪除欄位</a>
<table border="1" width="1363" id = "table2" style="display:none;">
<tr>
<td width="197" height="36" bgcolor="#99CCFF" align="center">
</td>
<td width="197" height="36" bgcolor="#99CCFF" align="center">
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">受控制個體名稱</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">Name of the
Related Party</font></td>
<td width="155" height="36" bgcolor="#99CCFF" align="center">
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">
受控制個體註冊地</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">
Place of Incorporation</font></td>
<td width="101" height="36" bgcolor="#99CCFF" align="center">
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">統一編號*</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">Taiwan GUI
No. *</font></td>
<td width="353" height="36" bgcolor="#99CCFF" align="center">
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">台積公司及其子公司名稱</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">Entity in
TSMC Group</font></td>
<td width="164" height="36" bgcolor="#99CCFF" align="center">
<p style="margin-top: 0; margin-bottom: 0">
<font face="微軟正黑體" size="2">交易型態</font></p>
<font face="微軟正黑體" size="2">Transaction Type</font></td>
<td width="93" height="36" bgcolor="#99CCFF"...
JavaScript
var countMin_2 = 1;
var countMax_2 = 10;
var commonName2_2 = "lot_";
var commonName4_2 = "effect_date_";
var count_2 = countMin_2;
function abbytest() {
var ck = document.getElementById("Check1")
if (check.checked) {
var ts = document.getElementById("table2")
ts.style.display="table"
} else {
alert("無新增欄位可以刪除");
}
}
function delField_2() {
if (count_2 > countMin_2) {
var fs = document.getElementById("fieldSpace_2");
fs.removeChild(fs.lastChild);
var ts = document.getElementById("table2")
ts.style.display="table"
count_2--;
} else {
alert("無新增欄位可以刪除");
ts.style.display="none"
}
}
function addField_2() {
if(count_2 == countMax_2)
alert("最多"+countMax_2+"個欄位");
else
document.getElementById("fieldSpace_2").innerHTML += "<div>" + (++count_2) + '-批號:<input type="text" name="' + commonName2_2 + count_2 + '" size="10">、有效日期:<input type="text" name="' + commonName4_2 + count_2 + '" size="10" value="<?=$time?>" class="calendarSelectDate"><div id="calendarDiv"></div><input type="hidden" name="lot[]" value="'+ count_2 +'"></div>';
}