1.动态表单的界面,从csdn论坛上参考
<html>
<cabeça>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<linguagem script="javascript">
var curRow=null;
var y=1;
função selectRow(){
var e=janela.evento;
var tr1=e.srcElement;
if(curRow)
curRow.bgColor="#FFFFFF";
tr1.bgColor="e7e7e7";
curRow=tr1;
}
function addRow(src){
//alerta(src);
var novalinha = src.insertRow(src.rows.length-1);
newrow.attachEvent("onclick",selectRow);
novalinha.height=20;
var i=4;
enquanto(eu--){
var novacélula = newrow.insertCell();
mudar(eu){
caso 0: newcell.innerHTML= '<input type="button" onClick="javascript:delRow(this.parentElement.parentElement)" value="删除此行">'+(y++);
document.all.count.value=y-1;
quebrar;
caso 1:newcell.innerHTML=div2.innerHTML;quebra;
caso 2:newcell.innerHTML=div3.innerHTML;quebra;
caso 3:newcell.innerHTML=div4.innerHTML;quebra;
padrão: newcell.innerHTML=div1.innerHTML;quebra;
}
}
//alert(newrow.outerHTML);
}
função delRow(src){
var tab=src.parentElement;
var i=tab.rows.length;
var j=tab.rows.length;
enquanto(eu--){
if(src==tab.rows[i]){
//alert("就是这行----"+ i);
document.all.count.value=j-3;
tab.deleteRow(i);
}
}
}
</script>
</head>
<corpo>
<form name="form1" action="2.asp" method="post" onsubmit=return(checkv())>
<h3>请输入经销商的通讯信息:</h3>
Aqui: <input type="text" name="jxname"><br>
Aqui: <input type="text" name="jxadd"><br>
Descrição: <input type="text" name="jxtel"><br>
请输入库存信息<br>
<table id="tb" width="100%" border="1" align="center" cellpadding="1" cellpacing="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>
</tabela>
<input type="hidden" name="contagem" valor="contagem">
<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" valor ="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>
<linguagem script="javascript">
verificação de funçãov()
{
if (form1.jxnome.valor.comprimento == 0)
{
alert("请填写姓名和地址!");
form1.jxname.focus();
retornar falso;
}
else if(!(check_number(form1.id1.value)))
{
alert("数量只能为数字")
form1.id1.focus();
retornar falso;
}
outro
retornar (verdadeiro);
}
função check_number(meuint)
{
var verificaçãoOK = "0123456789";
var checkStr = meuint;
var allValid = verdadeiro;
var pontosdec = 0;
var todosNum = "";
para (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
para (j = 0; j < checkOK.length; j++)
if (ch == verificarOK.charAt(j))
quebrar;
if (j == verificarOK.comprimento)
{
tudoValido = falso;
quebrar;
}
todosNum += ch;
}
if (!allValid)
{
retornar (falso);
}
retornar (verdadeiro);
}
</script>
</html>
2. 2.asp文件
<%
'//////////////////取表单数据
resposta.write("共"+request.form("contagem")+"contagem")
i=request.form("contagem")
jxname=request.form("jxname")
jxadd=request.form("jxadd")
jxtel=request.form("jxtel")
resposta.write(request.form("jxname"))
resposta.write("<br>")
resposta.write(request.form("jxadd"))
resposta.write("<br>")
resposta.write(request.form("jxtel"))
resposta.write("<br>")
str1=trim(request.form("id1"))
str2=trim(request.form("id2"))
str3=trim(request.form("id3"))
arrayA=Dividir(str1,",")
arrayb=Dividir(str2,",")
arrayc=Split(str3,",")
Para i = 0 para UBound(arrayA)
Resposta.Write "<LI>" & arrayc(i)&"--"&arrayb(i)&"--"&arrayA(i)
Próximo
'//////////////////写入xml文件
Dim objDom
Dim objRoot
Dim objChild1
Dim objChild2
Dim objChild3
dim objChild4
Dim objPI
Escurecer PINode
Definir objDom = Server.CreateObject("Microsoft.XMLDOM")
'/////写入样式
Definir PINode=objDom.CreateProcessingInstruction("xml-stylesheet", "type='text/xsl'
href='list.xsl'")
objDom.appendchild PINode
'/////创建根接点
Definir objRoot = objDom.createElement("kucunbiao")
objDom.appendChild objRoot
Definir objChild1 = objDom.createElement("jxname")
objChild1.text=jxname
objRoot.appendChild objChild1
Definir objChild2 = objDom.createElement("jxadd")
objchild2.text=jxadd
objRoot.appendChild objChild2
definir objChild3=objDom.createElement("jxtel")
objChild3.text=jxtel
objRoot.appendChild objChild3
definir objChild4=objDom.createElement("kucun")
objRoot.appendChild objChild4
Para i = 0 para UBound(arrayA)
Set objField = objDom.createElement("field")
'创建属性taborder。
Set objattTabOrder = objDom.createAttribute("taborder")
'设定taborder的属性值
objattTabOrder.Text = i
'taborder的属性值追加到field元素中去。
objField.setAttributeNode objattTabOrder
'创建一个新的元素field_value.
Definir objFieldValue2= objDom.createElement("nome")
objFieldValue2.Text = arrayc(i)
Definir objFieldValue = objDom.createElement("guige")
objFieldValue.Text = arrayb(i)
definir objFieldValue1=objDom.createElement("shuliang")
objFieldValue1.Text = arrayA(i)
'追加campo元素为根元素的子元素。
objChild4.appendChild objField
'追加field_value做为子元素的内容
objField.appendChild objFieldValue
objField.appendChild objFieldValue1
objField.appendChild objFieldValue2
próximo
Definir objPI = objDom.createProcessingInstruction("xml","version='1.0'")
objDom.insertBefore objPI, objDom.childNodes(0)
objDom.Save "f:xml"&jxname&".xml"
'/////////释放资源
Definir objDom = Nada
Definir objRoot = Nada
Definir objField = Nada
Definir objFieldValue = Nada
Definir objattID = Nada
Definir objattTabOrder = Nada
Definir objPI = Nada
Definir PINode=Nada
%>
3. 用xsl显示提交的xml,list.xsl
<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform ">
<xsl:template match="/">
<html>
<body style="background:#DFEEBB"><esquerda>
<h3>姓名:<xsl:value-of select="kucunbiao/jxname"/></h3>
<h3>地址:<xsl:value-of select="kucunbiao/jxadd"/></h3>
<h3>电话:<xsl:value-of select="kucunbiao/jxtel"/></h3>
<tabela border="1" largura="600">
<xsl:apply-templates select="kucunbiao/kucun" >
</xsl:apply-templates>
</table></left>
</body>
</html>
</xsl:template>
<xsl:template match="kucun">
<tr>
<td width="60%"><div align="center">名称</div></td>
<td width="20%"><div align="center">规格</div></td>
<td width="20%"><div align="center">数量</div></td>
</tr>
<xsl:for-each select="campo">
<tr>
<td><xsl:valor-de select="nome"/></td>
<td><xsl:value-of select="guige"/></td>
<td><xsl:valor-de select="shuliang"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
感谢http://lucky.diy.myrice.com/index.html技术支持