我用JS写了个可以增加和删除行的动态表格,当填写后要提交到一个JSP2页面,并在JSP2中显示表格的内容,哪位大侠帮忙一下,在线等!!!
解决方案 »
- java读一个文件的路径问题
- 大家帮我看看 这是怎么回事?
- 面试题,请指教
- Struts 中下拉框取值的问题,,在线等待
- 高手帮忙看看这段程序那里错了,谢谢了!
- 急死人了,在线等待:在select top n语句中如何动态地给n传值?
- 提取数据再转存问题,再线等啊....谢谢
- TOMCAT4.1上配置SQLSERVER 2000数据库连接池,如何修SERVER.XML和WEB.XML
- 防止页面重复提交 求解
- 怎么用java实现向浏览器中添加一个功能插件?我是指Interner Explorer.
- 急聘网站开发工程师2名,北京,JAVA+++++++++++++++++++++++++++++++++++++
- Struts 问题求救
allCount=1
function addline()
{
newRow=table.insertRow(table.rows.length-1);
newRow.ln=allCount;
newRow.id=allCount;
c1=newRow.insertCell(0);
c1.bgColor="#FFFFFF";
c1.innerHTML="<div align=center><input type=text id=room"+allCount+"name=room"+allCount+">"+allCount+"</div>";
c2=newRow.insertCell(1);
c2.bgColor="#FFFFFF";
c2.innerHTML="<div align=center><input name=p"+allCount+"type=text id=p"+allCount+">"+allCount+"</div>";
c3=newRow.insertCell(2);
c3.bgColor="#FFFFFF";
c3.innerHTML="<div align=center><input name=price"+allCount+"type=text id=price"+allCount+">"+allCount+"</div>";
c4=newRow.insertCell(3);
c4.bgColor="#FFFFFF";
c4.innerHTML="<input type=radio name=hasb"+allCount+" value=1 />有<input name=hasb"+allCount+" type=radio value=0 checked />无";
c5=newRow.insertCell(4);
c5.bgColor="#FFFFFF";
c5.innerHTML="<div align=center><input type=checkbox name=checkbox"+allCount+" value=1></div>";
c6=newRow.insertCell(5);
c6.bgColor="#FFFFFF";
c6.align="CENTER";
c6.id="line"+allCount;
c6.innerHTML="<input type=button value=删除 onclick=delline(line"+allCount+")>";
c7=newRow.insertCell(6);
c7.bgColor="#FFFFFF";
c7.align="CENTER";
c7.innerHTML="<input type=button value=插入 onclick=insertline(line"+allCount+")>";
allCount++
}...............................
没有jsp的代码吗?
这样传值应该不难啊
QQ:24699227
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
<title>
jsp1
</title>
</head>
<script language="javascript" type="">
allCount=1
function addline()
{
newRow=table.insertRow(table.rows.length-1);
newRow.ln=allCount;
newRow.id=allCount;
c1=newRow.insertCell(0);
c1.bgColor="#FFFFFF";
c1.innerHTML="<div align=center><input type=text id=room"+allCount+"name=room"+allCount+">"+allCount+"</div>";
c2=newRow.insertCell(1);
c2.bgColor="#FFFFFF";
c2.innerHTML="<div align=center><input name=p"+allCount+"type=text id=p"+allCount+">"+allCount+"</div>";
c3=newRow.insertCell(2);
c3.bgColor="#FFFFFF";
c3.innerHTML="<div align=center><input name=price"+allCount+"type=text id=price"+allCount+">"+allCount+"</div>";
c4=newRow.insertCell(3);
c4.bgColor="#FFFFFF";
c4.innerHTML="<input type=radio name=hasb"+allCount+" value=1 />有<input name=hasb"+allCount+" type=radio value=0 checked />无";
c5=newRow.insertCell(4);
c5.bgColor="#FFFFFF";
c5.innerHTML="<div align=center><input type=checkbox name=checkbox"+allCount+" value=1></div>";
c6=newRow.insertCell(5);
c6.bgColor="#FFFFFF";
c6.align="CENTER";
c6.id="line"+allCount;
c6.innerHTML="<input type=button value=删除 onclick=delline(line"+allCount+")>";
c7=newRow.insertCell(6);
c7.bgColor="#FFFFFF";
c7.align="CENTER";
c7.innerHTML="<input type=button value=插入 onclick=insertline(line"+allCount+")>";allCount++
}
function insertline(lineid)
{
for(i=0;i<table.rows.length;i++)
{
if(table.rows[i].cells[5].id==lineid.id)
{
newRow=table.insertRow(i);
newRow.ln=allCount;
newRow.id=allCount;
c1=newRow.insertCell(0);
c1.bgColor="#FFFFFF";
c1.innerHTML="<div align=center><input type=text id=room"+allCount+"name=room"+allCount+"></div>";
c2=newRow.insertCell(1);
c2.bgColor="#FFFFFF";
c2.innerHTML="<div align=center><input name=p"+allCount+" type=text id=p"+allCount+"></div>";
c3=newRow.insertCell(2);
c3.bgColor="#FFFFFF";
c3.innerHTML="<div align=center><input name=price"+allCount+"type=text id=price"+allCount+"></div>";
c4=newRow.insertCell(3);
c4.bgColor="#FFFFFF";
c4.innerHTML="<input type=radio name=hasb"+allCount+" value=1 />有<input name=hasb"+allCount+" type=radio value=0 checked />无";
c5=newRow.insertCell(4);
c5.bgColor="#FFFFFF";
c5.innerHTML="<div align=center><input type=checkbox name=checkbox"+allCount+" value=1></div>";
c6=newRow.insertCell(5);
c6.bgColor="#FFFFFF";
c6.align="CENTER";
c6.id="line"+allCount;
c6.innerHTML="<input type=button value=删除 onclick=delline(line"+allCount+")>";
c7=newRow.insertCell(6);
c7.bgColor="#FFFFFF";
c7.align="CENTER";
c7.innerHTML="<input type=button value=插入 onclick=insertline(line"+allCount+")>";
allCount++return;
}
}
}
function delline(lineid)
{
for(i=0;i<table.rows.length;i++)
{
for(j=0;j<table.rows[i].cells.length;j++)
{
if(table.rows[i].cells[j].id==lineid.id)
{
table.deleteRow(i);
return;
}
}
}
}</script>
<body>
<form id="form1" name="form1" method="post" action="jsp2.jsp"><table width="772" border="1" align="center" cellspacing="0" id="table" >
<tr>
<td width="23%"><div align="center">房型</div></td>
<td width="23%"><p align="center">门市价格</p> </td>
<td width="23%"><div align="center">本站价格</div></td>
<td width="13%"><div align="center">早餐</div></td>
<td width="7%"><div align="center">促销</div></td>
<td bordercolor="#FFFFFF" > </td>
<td bordercolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="7"><input type="button" name="Submit3" value="增加行" onclick="addline()" />
<input type="submit" name="Submit" value="提交" /> </td>
</tr>
</table>
</form>
</html>