for(i=1;i<=count;i++){
tabName="tabAffiche"+i; //表名
var t=document.getElementById(tabName);
if(t!=null){
var tabInput="";
for(j = 0;j < t.rows.length ;j++)
{
trName=t.rows[j].cells[1].getElementsByTagName("INPUT")[0].id;
var trValue=document.getElementById(trName).value;
tabInput+=trValue+","; //列的数据
}
tabInput=tabInput.substring(0,tabInput.length-1);
sqlStr+=tabInput+"/"; //行的数据
}
}
if(sqlStr.length>0){
sqlStr=sqlStr.substring(0,sqlStr.length-1);
}
//循环遍利TABLE的值
----------------------
//继续添加包
function AddBao()
{
var CbInvite =document.getElementById('ctl00_ContentPlaceHolder1_rbtnListfenbiao_0');//不分标包
document.getElementById("trJiXu").style.display="";
var count=0;
var lbBao=document.getElementById('<%=HiddenFieldAddBao.ClientID %>').value;
count=parseInt(lbBao)+1;
var lbText=document.getElementById('<%=lbJiXu.ClientID %>');
var tab=" <table class='tinputbody' cellspacing='1' cellpadding='0' width='100%' align='center' border='0' id='tabAffiche"+lbBao+"'>";
tab=tab+" <tr><td class='tabletitle'><strong><span style='color: Red'>*</span></strong>标包名称:</td>";
tab=tab+" <td class='tabletxtOne'>"
tab=tab+" <input id='TxtObjectName"+lbBao+"' type='text' maxlength='60' name='trffiche"+lbBao+"' size='60' />";
tab=tab+" <input id='BtnDel"+lbBao+"' type='button' value='删除' name='trffiche"+lbBao+"' onclick='Del(tabAffiche"+lbBao+");' /></td>";
tab=tab+" </tr><tr><td class='tabletitle'><strong><span style='color: Red'>*</span></strong>中标人名称:</td>";
tab=tab+" <td class='tabletxtOne'>";
tab=tab+" <input id='TxtGetbid_company_name"+lbBao+"' type='text' maxlength='60' name='trffiche"+lbBao+"' size='60'/></td>";
tab=tab+" </tr><tr><td class='tabletitle'>中标人地址:</td><td class='tabletxtOne'>";
tab=tab+" <input id='TxtGetbid_company_address"+lbBao+"' type='text' maxlength='80' name='trffiche"+lbBao+"' size='60' /></td>";
tab=tab+" </tr><tr><td class='tabletitle'><strong><span style='color: Red'>*</span></strong>中标总价:</td>";
tab=tab+" <td class='tabletxtOne'><input id='TxtGetbid_price"+lbBao+"' type='text' maxlength='20' size='60' name='trffiche"+lbBao+"' /></td>";
tab=tab+" </tr></table>";
document.getElementById('<%=HiddenFieldAddBao.ClientID %>').value= count+"";
lbText.innerHTML=lbText.innerHTML+tab;
}
这个表格及文本框是用调用上面的JS输出的,在查看源代码的时候,无法找到:可以这样取得值
for(i = 0;i < document.forms["aspnetForm"].length; i++)
{
name=document.forms["aspnetForm"][i].id;
value=document.forms["aspnetForm"][i].value;
for(j=0;j<count;j++)
{
//判断
temp1="TxtObjectName"+j.toString();
temp2="TxtGetbid_company_name"+j.toString();
temp3="TxtGetbid_company_address"+j.toString();
temp4="TxtGetbid_price"+j.toString();
if(name==temp1)
{
if(value=="")
{
alert("标包名称不能为空!");
document.forms["aspnetForm"][i].focus();
return false ;
}else if(value==objectName){
alert("标包名称不能重复");
document.forms["aspnetForm"][i].focus();
return false ;
}
}
if(name==temp2)
{
if(value==""){
alert("中标人名称不能为空!");
document.forms["aspnetForm"][i].focus();
return false;
}
}
if(name==temp3)
{
if(value==""){
TrValue=TrValue+"zbfwcgw"+","
}
}
if(name==temp4)
{
if(value=="")
{
alert("中标总价不能为空!");
document.forms["aspnetForm"][i].focus();
return false ;
}
else if(!value.match(regM))
{
alert("中标总价请输入数字!");
document.forms["aspnetForm"][i].focus();
return false ;
}
}//if
}//for
} //for
} //if
arr_value= new Array();
var k=0;
for( m=0;m<count;m++)
{
a="";
b="";
c="";
d="";
// var z=m+1;
temp1="TxtObjectName"+m.toString();
temp2="TxtGetbid_company_name"+m.toString();
temp3="TxtGetbid_company_address"+m.toString();
temp4="TxtGetbid_price"+m.toString();
for(n=0;n<document.forms["aspnetForm"].length;n++){
name=document.forms["aspnetForm"][n].id;
value=document.forms["aspnetForm"][n].value;
if(temp1==name){
a=value;
}
if(temp2==name){
b=value
}
if(temp3==name){
if(value==""){
value="ΨzbfwgsΨ";
}
c=value;
}
if(temp4==name){
d=value
}
} //for
if(a!="" && b!="" && c!="" && d!=""){
arr_value[m]=new Array(); //定义二维数组 ,同时在*.asmx页面中接受二维数据
arr_value[m][0]=a;
if(m>0){
if(arr_value[m-1][0]==arr_value[m][0]){
alert("标包名称不能重复");
document.getElementById(temp1).focus();
return false ;
}
}
arr_value[m][1]=b;
arr_value[m][2]=c;
arr_value[m][3]=d;
}
}//for
}
//删除TABLE
function Del(tabID){
var value= document.getElementById("ctl00_ContentPlaceHolder1_lbJiXu"); //lable控件接受输出JS表格
value.removeChild(tabID);
var lbBao=document.getElementById('<%=HiddenFieldAddBao.ClientID %>');
}
asmx页面中:接受JS二维数组
object[] temp = (object[])array3;
for (int i = 0; i < temp.Length; i++)
{
if (temp[i] != null)//创建动态添加的标包数据
{
object[] bb = (object[])temp[i];
string a = (string)bb[0];
CreateAfficheBidder(bb);
}
}
-----------------------------
newRow = tb4.insertRow();
newCell = newRow.insertCell();
newCell.align = "center ";
newCell.width=300;
newCell.innerHTML = " <input type= 'text ' name= 'EmployerFour ' style= 'width: 300px ' class= 'UnderlineTextBoxLight ' /> ";
aspx.cs后台用Request.Form( "EmployerFour ")来获取这个input的值
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%=para %><asp:Label ID="lbJiXu" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnJiXu" EventName="Click" />
</Triggers>
</asp:UpdatePanel>//不刷新