当前位置:编程学习 > JAVA >>

紧急求助~js添加动态文本框错误位了,搞上一个上午没搞好

看下图~怎么也调不好,除非把第一个<tr>删除它就正常了,这是什么问题呀?
搞了一个上午,崩溃了



<title>无标题文档</title>
<style type="text/css">
.div_row{border:none; border-bottom:dotted 1px gray; }
.div_row2{border:none; border-bottom: solid 1px gray; }
.vendor{ width:80px; margin-bottom:2px; margin-top:2px;}
.ipn{ width:120px;margin-bottom:2px; margin-top:2px;}
.datecode{ width:120px;margin-bottom:2px; margin-top:2px;}
.qty{ width:60px;margin-bottom:2px; margin-top:2px;}
.workno{ border:#999 solid 1px; width:100px; background-color:#CCC; font-size:14px; font-weight:bold; height:24px; }
.modelid{ border:#999 solid 1px; width:150px; background-color:#CCC; font-size:14px; font-weight:bold; height:24px;}
.lotqty{ border:#999 solid 1px; width:60px; background-color:#CCC; font-size:14px; font-weight:bold; height:24px;}
.trsdate{ border:#999 solid 1px; width:150px; background-color:#CCC; font-size:14px; font-weight:bold; height:24px;}
</style>
<script type="text/javascript">

//var num=1
function addvendor(a,b,c){
//alert (a+b+c)
//return false;
document.getElementById("showvendor"+a).style.display="block"
var AssCode = document.createElement("input"); //創建測試項目ID input
        AssCode.type = "hidden";
        AssCode.id = "AssCode"+num;
AssCode.name = "AssCode"+num;
AssCode.value=b
document.getElementById("show_AssCode_div"+a).appendChild(AssCode);

var AssName = document.createElement("input"); //創建測試項目ID input
        AssName.type = "hidden";
        AssName.id = "AssName"+num;
AssName.name = "AssName"+num;
AssName.value=b
document.getElementById("show_AssName_div"+a).appendChild(AssName);

var iPN2 = document.createElement("input"); //創建測試項目ID input
        iPN2.type = "hidden";
        iPN2.id = "iPN2"+num;
iPN2.name = "iPN2"+num;
iPN2.value=c
document.getElementById("show_iPN2_div"+a).appendChild(iPN2);

var vendor = document.createElement("select"); //創建測試項目ID input
vendor.className = "vendor";
        vendor.id = "vendor"+num;
vendor.name = "vendor"+num;
vendor.options[0] = new Option( '請選擇 ', ''); 

document.getElementById("show_vendor_div"+a).appendChild(vendor);

var iPN = document.createElement("input"); //創建測試項目ID input
        iPN.type = "text";
iPN.className = "ipn";
        iPN.id = "iPN"+num;
iPN.name = "iPN"+num;
document.getElementById("show_iPN_div"+a).appendChild(iPN);

var DateCode = document.createElement("input"); //創建測試項目ID input
        DateCode.type = "text";
DateCode.className = "datecode";
        DateCode.id = "DateCode"+num;
DateCode.name = "DateCode"+num;
document.getElementById("show_DateCode_div"+a).appendChild(DateCode);

var qty = document.createElement("input"); //創建測試項目ID input
        qty.type = "text";
qty.className = "qty";
        qty.id = "qty"+num;
qty.name = "qty"+num;
document.getElementById("show_qty_div"+a).appendChild(qty);

num++;
    document.getElementById("num").value=num-1;
//alert(a)
}

</script>
</head>

<body>
<% for i= 1 to 10 %>
<table width="880" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="80" height="30"><input type="button" name="button" id="button" value="AddVendor" onclick="addvendor(<%=i%>,document.getElementById('AssCode'+<%=i%>).value,document.getElementById('iPN2'+<%=i%>).value)" />
                      <input name="AssCode<%=i%>" type="hidden" id="AssCode<%=i%>"  /></td>
                    <td width="150" height="30">
                      <input name="AssName<%=i%>" type="hidden" id="AssName<%=i%>"  /></td>
                    <td width="150" height="30">
                      <input name="iPN2<%=i%>" type="hidden" id="iPN2<%=i%>"  /></td>
                    <td width="100" height="30"><label for="select2"></label>
                      <select name="VendorCode<%=i%>" class="vendor" id="select2">
                        <option>請選擇</option>
                      </select></td>
                    <td width="150" height="30"><label for="iPN<%=i%>"></label>
                      <input name="iPN<%=i%>" type="text" class="ipn" id="iPN<%=i%>" /></td>
                    <td width="150" height="30"><label for="DateCode<%=i%>"></label>
                      <input name="DateCode<%=i%>" type="text" class="datecode" id="DateCode<%=i%>" /></td>
                    <td width="100" height="30"><label for="qty<%=i%>"></label>
                      <input name="qty<%=i%>" type="text" class="qty" id="qty<%=i%>" /></td>
                  </tr>
                  <tr id="showvendor<%=i%>" style="display:none;">
                    <td width="80"><div id="show_AssCode_div<%=i%>"></div></td>
                    <td width="150"><div id="show_AssName_div<%=i%>"></div></td>
                    <td width="150"><div id="show_iPN2_div<%=i%>"></div></td>
                    <td width="100"><div id="show_vendor_div<%=i%>"></div></td>
                    <td width="150"><div id="show_iPN_div<%=i%>"></div></td>
                    <td width="150"><div id="show_DateCode_div<%=i%>"></div></td>
                    <td width="100"><div id="show_qty_div<%=i%>"></div></td>
                  </tr>
                </table>
<%next%>
<input name="num" id="num" type="text" value="<%=i%>" />
<script type="text/javascript">
num = document.getElementById("num").value
</script>
</body>


--------------------编程问答-------------------- 自己已搞定 --------------------编程问答-------------------- 怎么搞定的,说来听听啊,过程。。。
--------------------编程问答-------------------- 这种用表格的 样式都很难调,跳过多少行 多少列一定要清楚,建议多用DIV
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,