<HTML>
<SCRIPT LANGUAGE="Javascript">
function numberCells()
{
}function tb_addnew()
{
var ls_t=document.all("mytable")
maxcell=ls_t.rows(0).cells.length;
mynewrow = ls_t.insertRow();
mynewcell=mynewrow.insertCell();
mynewcell.innerText=document.all.mytable.rows.length -1 mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.model.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.process_no.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.process_name.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.process_time.value;
mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.equipment.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.content.value;
}function tb_delete()
{
var ls_t=document.all("mytable");ls_t.deleteRow() ;
}</SCRIPT>
<BODY onload="numberCells()">
<form name="process_input" method="post" action="process_input.jsp">
<table id=mytable width=98% border="1" cellspacing="0" cellpadding="0" align="center" bordercolordark=white>
<tr>
<th width=10% height="24">序号</th>
<th width=14% height="24">工件型号</th>
<th width=14% height="24">工序步数</th>
<th width=16% height="24">工序名称</th>
<th width=16% height="24">工序时间 </th>
<th width=15% height="24">使用设备</th>
<th width=15% height="24">备注</th>
</tr>
</table>
<table bordercolordark=#ccccff width="60%" bordercolorlight=#000000 border=0>
<tbody>
<tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <a href="#" style="COLOR: #000066; TEXT-DECORATION: none" tabindex=-1 title=工件的唯一标识。 >
<font color="#ff0000">*</font> 工序型号: </a> </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name="model">
</td>
</tr>
<tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
工序步数: </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name=process_no>
</td>
</tr>
<tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
工序名称: </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name=process_name>
</td>
</tr> <tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
工序时间: </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name=process_time>
</td>
</tr>
<tr>
<td width="40%" align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
使用设备: </td>
<td width="60%">
<select name="equipment">
<option>--请选择--</option>
<option value="1">roughlathe</option>
<option value="2">jingche</option>
<option value="3">milling</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right" bgcolor="#e8eeff"> <font color="#ff0000"></font>
备注: </td>
<td width="60%">
<input maxlength=10 name=content size="20" > </td>
</tr>
</tbody>
</table>
<input type="button" value="新增" onClick="tb_addnew()" name="new">
<input type="button" value="删除" onClick="tb_delete()" name="delete" >
</form></BODY>
</HTML>这是看了一个CSDN朋友的代码后改的,挺好的,但这里没有实际数据库的操作,问个问题:
假设增加数据的程序是A.JSP
删除数据的程序是B.JSP
请各位看看该如何再实现数据库实际操作的同时,维持上面HTML中的表格视图的动态增减?
大家帮忙了!!!
<SCRIPT LANGUAGE="Javascript">
function numberCells()
{
}function tb_addnew()
{
var ls_t=document.all("mytable")
maxcell=ls_t.rows(0).cells.length;
mynewrow = ls_t.insertRow();
mynewcell=mynewrow.insertCell();
mynewcell.innerText=document.all.mytable.rows.length -1 mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.model.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.process_no.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.process_name.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.process_time.value;
mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.equipment.value; mynewcell=mynewrow.insertCell();
mynewcell.innerText=process_input.content.value;
}function tb_delete()
{
var ls_t=document.all("mytable");ls_t.deleteRow() ;
}</SCRIPT>
<BODY onload="numberCells()">
<form name="process_input" method="post" action="process_input.jsp">
<table id=mytable width=98% border="1" cellspacing="0" cellpadding="0" align="center" bordercolordark=white>
<tr>
<th width=10% height="24">序号</th>
<th width=14% height="24">工件型号</th>
<th width=14% height="24">工序步数</th>
<th width=16% height="24">工序名称</th>
<th width=16% height="24">工序时间 </th>
<th width=15% height="24">使用设备</th>
<th width=15% height="24">备注</th>
</tr>
</table>
<table bordercolordark=#ccccff width="60%" bordercolorlight=#000000 border=0>
<tbody>
<tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <a href="#" style="COLOR: #000066; TEXT-DECORATION: none" tabindex=-1 title=工件的唯一标识。 >
<font color="#ff0000">*</font> 工序型号: </a> </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name="model">
</td>
</tr>
<tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
工序步数: </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name=process_no>
</td>
</tr>
<tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
工序名称: </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name=process_name>
</td>
</tr> <tr>
<td width="40%" height=31 align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
工序时间: </td>
<td width="60%" height=31>
<input maxlength=50 size=30 name=process_time>
</td>
</tr>
<tr>
<td width="40%" align="right" bgcolor="#e8eeff"> <font color="#ff0000">*</font>
使用设备: </td>
<td width="60%">
<select name="equipment">
<option>--请选择--</option>
<option value="1">roughlathe</option>
<option value="2">jingche</option>
<option value="3">milling</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right" bgcolor="#e8eeff"> <font color="#ff0000"></font>
备注: </td>
<td width="60%">
<input maxlength=10 name=content size="20" > </td>
</tr>
</tbody>
</table>
<input type="button" value="新增" onClick="tb_addnew()" name="new">
<input type="button" value="删除" onClick="tb_delete()" name="delete" >
</form></BODY>
</HTML>这是看了一个CSDN朋友的代码后改的,挺好的,但这里没有实际数据库的操作,问个问题:
假设增加数据的程序是A.JSP
删除数据的程序是B.JSP
请各位看看该如何再实现数据库实际操作的同时,维持上面HTML中的表格视图的动态增减?
大家帮忙了!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货