asp取动态表单中数据并写入xml文件,用xsl显示
2008-02-23 05:31:41来源:互联网 阅读 ()
1.动态表单的界面,从csdn论坛上参考
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
var curRow=null;
var y=1;
function selectRow(){
var e=window.event;
var tr1=e.srcElement;
if(curRow)
curRow.bgColor="#FFFFFF";
tr1.bgColor="e7e7e7";
curRow=tr1;
}
function addRow(src){
//alert(src);
var newrow = src.insertRow(src.rows.length-1);
newrow.attachEvent("onclick",selectRow);
newrow.height=20;
var i=4;
while(i--){
var newcell = newrow.insertCell();
switch(i){
case 0: newcell.innerHTML= '<input type="button" onClick="javascript:delRow(this.parentElement.parentElement)" value="删除此行">' (y );
document.all.count.value=y-1;
break;
case 1:newcell.innerHTML=div2.innerHTML;break;
case 2:newcell.innerHTML=div3.innerHTML;break;
case 3:newcell.innerHTML=div4.innerHTML;break;
default: newcell.innerHTML=div1.innerHTML;break;
}
}
//alert(newrow.outerHTML);
}
function delRow(src){
var tab=src.parentElement;
var i=tab.rows.length;
var j=tab.rows.length;
while(i--){
if(src==tab.rows[i]){
//alert("就是这行----" i);
document.all.count.value=j-3;
tab.deleteRow(i);
}
}
}
</script>
</head>
<body>
<form name="form1" action="2.asp" method="post" onsubmit=return(checkv())>
<h3>请输入经销商的通讯信息:</h3>
姓 名: <input type="text" name="jxname"><br>
地 址: <input type="text" name="jxadd"><br>
电 话: <input type="text" name="jxtel"><br>
请输入库存信息<br>
<table id="tb" width="100%" border="1" align="center" cellpadding="1" cellspacing="1" style="border-collapse:collapse" bordercolor="#111111">
<tr>
<th scope="col" width="25%">品名</th>
<th scope="col" width="25%">规格</th>
<th scope="col" width="25%">库存量</th>
<th scope="col" width="25%">操作</th>
</tr>
<tr id="blankRow" onClick="addRow(this.parentElement)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<input type="hidden" name="count" value="count">
<input type="submit" id="btnSub" name="btnSub" value="提交"><br>
</form>
<div id="div1" style="display:none "><input id="txt" type="text" name="id" style="width:97%; background-color:#FFFFEF"></div>
<div id="div2" style="display:none "><input id="txt" type="text" name="id1" style="width:97%; background-color:#FFFFEF" value="11"></div>
</body>
<div id="div3" style="display:none "><select name="id2" style="width:97%; background-color:#FFFFEF" >
<option value="箱">箱</option>
<option value="件">件</option>
</select></div>
<div id="div4" style="display:none "><input id="txt" type="text" name="id3" style="width:97%; background-color:#FFFFEF" value="33"></div>
<script language="javascript">
function checkv()
{
if (form1.jxname.value.length == 0)
{
alert("请填写姓名和地址!");
form1.jxname.focus();
return false;
}
else if(!(check_number(form1.id1.value)))
{
alert("数量只能为数字")
form1.id1.focus();
return false;
}
else
return (true);
}
function check_number(myint)
{
var checkOK = "0123456789";
var checkStr = myint;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.length; i )
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j )
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
allNum = ch;
}
if (!allValid)
{
return (false);
}
return (true);
}
</script>
</html>
2. 2.asp文件
<%
'////////////////////取表单数据
response.write("共" request.form("count") "记录")
i=request.form("count")
jxname=request.form("jxname")
jxadd=request.form("jxadd")
jxtel=request.form("jxtel")
response.write(request.form("jxname"))
response.write("<br>")
response.write(request.form("jxadd"))
response.write("<br>")
response.write(request.form("jxtel"))
response.write("<br>")
str1=trim(request.form("id1"))
str2=trim(request.form("id2"))
str3=trim(request.form("id3"))
arrayA=Split(str1,",")
arrayb=Split(str2,",")
arrayc=Split(str3,",")
For i = 0 to UBound(arrayA)
Response.Write "<LI>" & arrayc(i)&"--"&arrayb(i)&"--"&arrayA(i)
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash