htm页面传递数据处理
时间:2008-06-30 来源:EricJava
在htm页面中对于数据的传递和处理的一些方法和总结:
A:对含有空格的字符串的处理:
function IgnoreSpaces(Str){
var ResultStr = "";
Temp=Str.split(" "); //双引号之间是个空格;
for(i = 0; i < Temp.length; i++)
ResultStr +=Temp[i];
return ResultStr;
} 清除字符串中的空格,应该不处理这个空格它在传递中会解析成20%之类的字符.使用方法直接为: var fname= IgnoreSpaces(document.getElementById("fname").value); B:在htm中使用xmldoc对xml数据的处理: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
</HEAD> <BODY>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="380" valign="top" bgcolor="#CC9900" align="center">
<table width="778" border="0" align="center" cellspacing="0" cellpadding="0">
<DIV align="center">
<form id="form1" runat="server">
<input type="button" value="保存单据记录" onclick="RWFile()" />
<input type="button" value="读取单据记录" onClick="RDFile()" />
</DIV>
</form>
<table width="100%" align="center" bgcolor="#219200" cellpadding="0" cellspacing="0"><tr height="23">
<td width="15%"><div align="center">发件日期</div></td>
<td width="10%"><div align="left">客户代码</div></td>
<td width="10%"><div align="left">发件人姓名</div></td>
<td width="10%"><div align="left">联系电话</div></td>
<td width="10%"><div align="left">收件人姓名</div></td>
<td width="10%"><div align="left">联系电话</div></td>
<td width="10%"><div align="left">快递方式</div></td>
<td width="10%"><div align="left">费用总计(元)</div></td>
<td width="10%"><div align="left">支付方式</div></td>
</tr></table>
<div align="center" id="result"></div>
<br> <DIV align="center">
<OBJECT id=wb height=0 width=0
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>
<INPUT onclick=javascript:printit() type=button value=打印
name=button_print /> <INPUT onclick=javascript:printsetup(); type=button value=打印页面设置
name=button_setup /> <INPUT onclick=javascript:printpreview(); type=button value=打印预览
name=button_show />
</DIV>
</table></td>
</tr>
</td>
</tr>
</table>
</BODY>
</HTML> C:支票的套打功能: <html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk"> <!-- 插入打印控件 -->
<OBJECT ID="jatoolsPrinter" CLASSID="CLSID:B43D3361-D975-4BE2-87FE-057188254255" codebase="jatoolsP.cab#version=1,2,0,5"></OBJECT>
<title>支票套打演示</title><style>
<!--
*{
-moz-box-sizing: border-box;
}
.title {
font-family : Arial,Vernada,Tahoma, sans-serif;
font-size: 30px;
color : #00008B;
background-color : White; text-decoration:underline
}
.normal{
font-family : Arial,Vernada, Tahoma, Helvetica, sans-serif;
font-size: 12px;
color: #444444;
text-decoration: none;
line-}
.hide_for_jatools_print{}
.jc{position:absolute;overflow:hidden}
.jnc{position:absolute}
.pb{overflow:hidden;position:relative;margin:5;width:890;background-color:white;
border-left:1px solid black;border-top:1px solid black; border-right:4px solid black;border-bottom:4px solid black;}
.c12{margin-left:2px;margin-bottom:-2px;font-family: 宋体;font-size: 24px;font-weight: bold;color: #FF0000}
.c9, .c8, .c6, .c5, .c4, .c3, .c0{margin-left:2px;margin-bottom:-2px;font-family: 宋体;font-size: 12px;}
.c2{margin-left:2px;margin-bottom:-2px;font-family: 宋体;font-size: 12px;}
.c7{margin-left:2px;margin-bottom:-2px;text-align: right;font-family: 宋体;font-size: 12px;}
.c11, .c10, .c1{margin-left:2px;margin-bottom:-2px;text-align: right;font-family: 宋体;font-size: 12px;}
--></style>
</head>
<body> </div></div></div> <table border="0" cellpadding="0" cellspacing="0" width="100%" id="AutoNumber1" height="206">
<tr align="center">
<td width="33%" height="206" valign="top"><input type="button" value="打印预览..." onClick="doPrint('打印预览...')">
<input type="button" value="打印..." onClick="doPrint('打印...')">
<input type="button" value="打印" onClick="doPrint('打印')"> </td>
</tr>
</table> <p> </p>
</body></html>
var ResultStr = "";
Temp=Str.split(" "); //双引号之间是个空格;
for(i = 0; i < Temp.length; i++)
ResultStr +=Temp[i];
return ResultStr;
} 清除字符串中的空格,应该不处理这个空格它在传递中会解析成20%之类的字符.使用方法直接为: var fname= IgnoreSpaces(document.getElementById("fname").value); B:在htm中使用xmldoc对xml数据的处理: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
</HEAD> <BODY>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="380" valign="top" bgcolor="#CC9900" align="center">
<table width="778" border="0" align="center" cellspacing="0" cellpadding="0">
<DIV align="center">
<form id="form1" runat="server">
<input type="button" value="保存单据记录" onclick="RWFile()" />
<input type="button" value="读取单据记录" onClick="RDFile()" />
</DIV>
</form>
<table width="100%" align="center" bgcolor="#219200" cellpadding="0" cellspacing="0"><tr height="23">
<td width="15%"><div align="center">发件日期</div></td>
<td width="10%"><div align="left">客户代码</div></td>
<td width="10%"><div align="left">发件人姓名</div></td>
<td width="10%"><div align="left">联系电话</div></td>
<td width="10%"><div align="left">收件人姓名</div></td>
<td width="10%"><div align="left">联系电话</div></td>
<td width="10%"><div align="left">快递方式</div></td>
<td width="10%"><div align="left">费用总计(元)</div></td>
<td width="10%"><div align="left">支付方式</div></td>
</tr></table>
<div align="center" id="result"></div>
<br> <DIV align="center">
<OBJECT id=wb height=0 width=0
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>
<INPUT onclick=javascript:printit() type=button value=打印
name=button_print /> <INPUT onclick=javascript:printsetup(); type=button value=打印页面设置
name=button_setup /> <INPUT onclick=javascript:printpreview(); type=button value=打印预览
name=button_show />
</DIV>
</table></td>
</tr>
</td>
</tr>
</table>
</BODY>
</HTML> C:支票的套打功能: <html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk"> <!-- 插入打印控件 -->
<OBJECT ID="jatoolsPrinter" CLASSID="CLSID:B43D3361-D975-4BE2-87FE-057188254255" codebase="jatoolsP.cab#version=1,2,0,5"></OBJECT>
<title>支票套打演示</title><style>
<!--
*{
-moz-box-sizing: border-box;
}
.title {
font-family : Arial,Vernada,Tahoma, sans-serif;
font-size: 30px;
color : #00008B;
background-color : White; text-decoration:underline
}
.normal{
font-family : Arial,Vernada, Tahoma, Helvetica, sans-serif;
font-size: 12px;
color: #444444;
text-decoration: none;
line-}
.hide_for_jatools_print{}
.jc{position:absolute;overflow:hidden}
.jnc{position:absolute}
.pb{overflow:hidden;position:relative;margin:5;width:890;background-color:white;
border-left:1px solid black;border-top:1px solid black; border-right:4px solid black;border-bottom:4px solid black;}
.c12{margin-left:2px;margin-bottom:-2px;font-family: 宋体;font-size: 24px;font-weight: bold;color: #FF0000}
.c9, .c8, .c6, .c5, .c4, .c3, .c0{margin-left:2px;margin-bottom:-2px;font-family: 宋体;font-size: 12px;}
.c2{margin-left:2px;margin-bottom:-2px;font-family: 宋体;font-size: 12px;}
.c7{margin-left:2px;margin-bottom:-2px;text-align: right;font-family: 宋体;font-size: 12px;}
.c11, .c10, .c1{margin-left:2px;margin-bottom:-2px;text-align: right;font-family: 宋体;font-size: 12px;}
--></style>
</head>
<body> </div></div></div> <table border="0" cellpadding="0" cellspacing="0" width="100%" id="AutoNumber1" height="206">
<tr align="center">
<td width="33%" height="206" valign="top"><input type="button" value="打印预览..." onClick="doPrint('打印预览...')">
<input type="button" value="打印..." onClick="doPrint('打印...')">
<input type="button" value="打印" onClick="doPrint('打印')"> </td>
</tr>
</table> <p> </p>
</body></html>
相关阅读 更多 +