代码如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>入库管理</title>
<?php
error_reporting(0);
session_start();
if ($_SESSION['role']==NULL or $_SESSION['name']==NULL)
{
echo"<script language=javascript>"; echo "location.href='index.php'";
echo "</script>";
}
?>
<script language="javascript" src="date.js"></script>
<script language="javascript" src="stop_click.js"></script>
<script language="javascript">// Example: obj = findObj("image1");
function findObj(theObj, theDoc){var p, i, foundObj;if(!theDoc) theDoc = document;if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){ theDoc = parent.frames[theObj.substring(p+1)].document; theObj = theObj.substring(0,p);}if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];for (i=0; !foundObj && i < theDoc.forms.length; i++) foundObj = theDoc.forms[i][theObj];for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) foundObj = findObj(theObj,theDoc.layers[i].document);if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);return foundObj;}
//添加一个参与人填写行
function AddSignRow(){//读取最后一行的行号,存放在txtTRLastIndex文本框中
var txtTRLastIndex = findObj("txtTRLastIndex",document);
var rowID = parseInt(txtTRLastIndex.value);var signFrame = findObj("SignFrame",document);
//添加行
var newTR = signFrame.insertRow(signFrame.rows.length);
newTR.id = "SignItem" + rowID;//添加列:序号
var newNameTD=newTR.insertCell(0);
//添加列内容
newNameTD.innerHTML = newTR.rowIndex.toString();
//添加列:材质
var newNameTD=newTR.insertCell(1);
//添加列内容
newNameTD.innerHTML = "<input name='material" + rowID + "' id='material" + rowID + "' type='text' size='12' />";
//添加列:规格
var newEmailTD=newTR.insertCell(2);
//添加列内容
newEmailTD.innerHTML = "<input name='norm" + rowID + "' id='norm" + rowID + "' type='text' size='20' />";
//添加列:支数
var newTelTD=newTR.insertCell(3);
//添加列内容
newTelTD.innerHTML = "<input name='quantity" + rowID + "' id='quantity " + rowID + "' type='text' size='10' />";
//添加列:重量
var newMobileTD=newTR.insertCell(4);
//添加列内容
newMobileTD.innerHTML = "<input name='weight" + rowID + "' id='weight " + rowID + "' type='text' size='12' />";
//添加列:公司名
// var newCompanyTD=newTR.insertCell(5);
//添加列内容
//newCompanyTD.innerHTML = "<input name='txtCompany" + rowID + "' id='txtCompany" + rowID + "' type='text' size='20' />";
//添加列:删除按钮
var newDeleteTD=newTR.insertCell(5);
//添加列内容
newDeleteTD.innerHTML = "<div align='center' style='width:40px'><a href='javascript:' onclick=\"DeleteSignRow('SignItem" + rowID + "')\">删除</a></div>";//将行号推进下一行
txtTRLastIndex.value = (rowID + 1).toString() ;
}
//删除指定行
function DeleteSignRow(rowid){
var signFrame = findObj("SignFrame",document);
var signItem = findObj(rowid,document);//获取将要删除的行的Index
var rowIndex = signItem.rowIndex;//删除指定Index的行
signFrame.deleteRow(rowIndex);txtTRLastIndex.value = (txtTRLastIndex.value - 1).toString() ;
//重新排列序号,如果没有序号,这一步省略
for(i=rowIndex;i<signFrame.rows.length;i++){
signFrame.rows[i].cells[0].innerHTML = i.toString();
}
}//清空列表
function ClearAllSign(){
if(confirm('确定要清空所有参与人吗?')){
var signFrame = findObj("SignFrame",document);
var rowscount = signFrame.rows.length;
//循环删除行,从最后一行往前删除
for(i=rowscount - 1;i > 0; i--){
signFrame.deleteRow(i);
}
//重置最后行号为1
var txtTRLastIndex = findObj("txtTRLastIndex",document);
txtTRLastIndex.value = "1";
//预添加一行
AddSignRow();
}
}
</script>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function goHist(a)
{
history.go(a);
}
//-->
</script>
<form name="in" method="post" action="in_check.php">
<table width="100%" border="1" align="center">
<tr>
<th colspan="3" scope="row" bgcolor="#96E0E2">入库管理模块——添加入库</th>
</tr>
<tr>
<th width="16%" scope="row" align="right">入库单号:</th>
<td width="35%"><input type="text" id="num" name="num" /></td>
<td width="49%">*填写入库单上序列号码(必填)。</td>
</tr>
<tr>
<th scope="row" align="right">来自:</th>
<td><input type="text" id="fromwhere" name="fromwhere" /></td>
<td>*填写入库货物来自何处(必填)。</td>
</tr>
<tr>
<th scope="row" align="right">日期:</th>
<td><input id="date" name="date" type="text" readonly="true" style="width:70px" onFocus="HS_setDate(this)"></td>
<td>*填写入库货物入库的时间(必填)。</td>
</tr>
<tr>
<th colspan="3" align="left" scope="row" bgcolor="#96E0E2">以下填写入库货物规格详情:</th>
</tr>
</table>
<table width=100% border="0" cellpadding="1" cellspacing="1" id="SignFrame" align="center"> <tr id="trHeader">
<td width="27" bgcolor="#96E0E2">序号</td>
<td width="64" bgcolor="#96E0E2">材质</td>
<td width="98" bgcolor="#96E0E2">规格(毫米)</td>
<td width="92" bgcolor="#96E0E2">支数(支)</td>
<td width="86" bgcolor="#96E0E2">重量(千克)</td>
<td width="57" align="center" bgcolor="#96E0E2"> </td>
</tr>
</table>
<div align="center">
<input type="button" name="Submit" value="新增货物" onclick="AddSignRow()" />
<input type="button" name="Submit2" value="清除所有" onclick="ClearAllSign()" />
<input name='txtTRLastIndex' type="text" id='txtTRLastIndex' value="1" />
</div>
<div align="center">
<hr/>
<input type="submit" value="确定添加" />
</div>
</form>
</body></html>
在添加form后,点击删除,txtTRLastIndex.value值没有变化,而删掉form后,点击删除就能够减1,不知道为什么,有人知道么?请指教
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>入库管理</title>
<?php
error_reporting(0);
session_start();
if ($_SESSION['role']==NULL or $_SESSION['name']==NULL)
{
echo"<script language=javascript>"; echo "location.href='index.php'";
echo "</script>";
}
?>
<script language="javascript" src="date.js"></script>
<script language="javascript" src="stop_click.js"></script>
<script language="javascript">// Example: obj = findObj("image1");
function findObj(theObj, theDoc){var p, i, foundObj;if(!theDoc) theDoc = document;if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){ theDoc = parent.frames[theObj.substring(p+1)].document; theObj = theObj.substring(0,p);}if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];for (i=0; !foundObj && i < theDoc.forms.length; i++) foundObj = theDoc.forms[i][theObj];for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) foundObj = findObj(theObj,theDoc.layers[i].document);if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);return foundObj;}
//添加一个参与人填写行
function AddSignRow(){//读取最后一行的行号,存放在txtTRLastIndex文本框中
var txtTRLastIndex = findObj("txtTRLastIndex",document);
var rowID = parseInt(txtTRLastIndex.value);var signFrame = findObj("SignFrame",document);
//添加行
var newTR = signFrame.insertRow(signFrame.rows.length);
newTR.id = "SignItem" + rowID;//添加列:序号
var newNameTD=newTR.insertCell(0);
//添加列内容
newNameTD.innerHTML = newTR.rowIndex.toString();
//添加列:材质
var newNameTD=newTR.insertCell(1);
//添加列内容
newNameTD.innerHTML = "<input name='material" + rowID + "' id='material" + rowID + "' type='text' size='12' />";
//添加列:规格
var newEmailTD=newTR.insertCell(2);
//添加列内容
newEmailTD.innerHTML = "<input name='norm" + rowID + "' id='norm" + rowID + "' type='text' size='20' />";
//添加列:支数
var newTelTD=newTR.insertCell(3);
//添加列内容
newTelTD.innerHTML = "<input name='quantity" + rowID + "' id='quantity " + rowID + "' type='text' size='10' />";
//添加列:重量
var newMobileTD=newTR.insertCell(4);
//添加列内容
newMobileTD.innerHTML = "<input name='weight" + rowID + "' id='weight " + rowID + "' type='text' size='12' />";
//添加列:公司名
// var newCompanyTD=newTR.insertCell(5);
//添加列内容
//newCompanyTD.innerHTML = "<input name='txtCompany" + rowID + "' id='txtCompany" + rowID + "' type='text' size='20' />";
//添加列:删除按钮
var newDeleteTD=newTR.insertCell(5);
//添加列内容
newDeleteTD.innerHTML = "<div align='center' style='width:40px'><a href='javascript:' onclick=\"DeleteSignRow('SignItem" + rowID + "')\">删除</a></div>";//将行号推进下一行
txtTRLastIndex.value = (rowID + 1).toString() ;
}
//删除指定行
function DeleteSignRow(rowid){
var signFrame = findObj("SignFrame",document);
var signItem = findObj(rowid,document);//获取将要删除的行的Index
var rowIndex = signItem.rowIndex;//删除指定Index的行
signFrame.deleteRow(rowIndex);txtTRLastIndex.value = (txtTRLastIndex.value - 1).toString() ;
//重新排列序号,如果没有序号,这一步省略
for(i=rowIndex;i<signFrame.rows.length;i++){
signFrame.rows[i].cells[0].innerHTML = i.toString();
}
}//清空列表
function ClearAllSign(){
if(confirm('确定要清空所有参与人吗?')){
var signFrame = findObj("SignFrame",document);
var rowscount = signFrame.rows.length;
//循环删除行,从最后一行往前删除
for(i=rowscount - 1;i > 0; i--){
signFrame.deleteRow(i);
}
//重置最后行号为1
var txtTRLastIndex = findObj("txtTRLastIndex",document);
txtTRLastIndex.value = "1";
//预添加一行
AddSignRow();
}
}
</script>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function goHist(a)
{
history.go(a);
}
//-->
</script>
<form name="in" method="post" action="in_check.php">
<table width="100%" border="1" align="center">
<tr>
<th colspan="3" scope="row" bgcolor="#96E0E2">入库管理模块——添加入库</th>
</tr>
<tr>
<th width="16%" scope="row" align="right">入库单号:</th>
<td width="35%"><input type="text" id="num" name="num" /></td>
<td width="49%">*填写入库单上序列号码(必填)。</td>
</tr>
<tr>
<th scope="row" align="right">来自:</th>
<td><input type="text" id="fromwhere" name="fromwhere" /></td>
<td>*填写入库货物来自何处(必填)。</td>
</tr>
<tr>
<th scope="row" align="right">日期:</th>
<td><input id="date" name="date" type="text" readonly="true" style="width:70px" onFocus="HS_setDate(this)"></td>
<td>*填写入库货物入库的时间(必填)。</td>
</tr>
<tr>
<th colspan="3" align="left" scope="row" bgcolor="#96E0E2">以下填写入库货物规格详情:</th>
</tr>
</table>
<table width=100% border="0" cellpadding="1" cellspacing="1" id="SignFrame" align="center"> <tr id="trHeader">
<td width="27" bgcolor="#96E0E2">序号</td>
<td width="64" bgcolor="#96E0E2">材质</td>
<td width="98" bgcolor="#96E0E2">规格(毫米)</td>
<td width="92" bgcolor="#96E0E2">支数(支)</td>
<td width="86" bgcolor="#96E0E2">重量(千克)</td>
<td width="57" align="center" bgcolor="#96E0E2"> </td>
</tr>
</table>
<div align="center">
<input type="button" name="Submit" value="新增货物" onclick="AddSignRow()" />
<input type="button" name="Submit2" value="清除所有" onclick="ClearAllSign()" />
<input name='txtTRLastIndex' type="text" id='txtTRLastIndex' value="1" />
</div>
<div align="center">
<hr/>
<input type="submit" value="确定添加" />
</div>
</form>
</body></html>
在添加form后,点击删除,txtTRLastIndex.value值没有变化,而删掉form后,点击删除就能够减1,不知道为什么,有人知道么?请指教
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货