40分求用javascript实现票据的套打功能!

luohuayh 2009-11-25 11:32:36
现急需一能实现票据套打的javascript代码,希望哪位大虾能帮帮忙!!!
也就是说按照固定的格式把相关的数据打出来,其中数据条数不一定,当当前页的票据打满后,自动打另一张票据。
...全文
845 50 打赏 收藏 转发到动态 举报
写回复
用AI写文章
50 条回复
切换为时间正序
请发表友善的回复…
发表回复
luohuayh 2009-12-01
  • 打赏
  • 举报
回复
唉,没人回答,只好结贴给分了,不过最后还是谢谢大家的帮忙!
luohuayh 2009-11-30
  • 打赏
  • 举报
回复
还有没有更好的思想呢?
luohuayh 2009-11-29
  • 打赏
  • 举报
回复
帖子不要沉,UP
luohuayh 2009-11-29
  • 打赏
  • 举报
回复
[Quote=引用 46 楼 pt1314917 的回复:]
后台方法就不需要贴了吧。不就是个根据当前页索引显示数据么?
[/Quote]
就是后台数据的问题,后台数据不会处理!
pt1314917 2009-11-29
  • 打赏
  • 举报
回复
后台方法就不需要贴了吧。不就是个根据当前页索引显示数据么?
pt1314917 2009-11-29
  • 打赏
  • 举报
回复
后台方法就不需要贴了吧。不就是个根据当前页索引显示数据么?
pt1314917 2009-11-29
  • 打赏
  • 举报
回复
[Quote=引用 42 楼 luohuayh 的回复:]
#38的挺好的,但不知数据获取那页能否也贴出来?
[/Quote]

这个分页是通过url传参进行分页的,所以只需要在后台显示当前页的数据就行了。。。。
比如如果打印的数据共4页,当前显示第一页:http://www.asd.com/wprint.aspx?pageindex=1&lastpage=4
luohuayh 2009-11-29
  • 打赏
  • 举报
回复
<%@ Control Language="c#" AutoEventWireup="false" Inherits="FLX.Portal.PageModeTemplate" %>
也就是这句中的FLX.Portal.PageModeTemplate
luohuayh 2009-11-29
  • 打赏
  • 举报
回复
#38的挺好的,但不知数据获取那页能否也贴出来?
itliyi 2009-11-29
  • 打赏
  • 举报
回复
[Quote=引用 38 楼 pt1314917 的回复:]
JScript code//参考;<%@ Control Language="c#" AutoEventWireup="false" Inherits="FLX.Portal.PageModeTemplate"%><style type="text/css"><!--
.STYLE1 {color: #FF0000}--></style><html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><!--media=print 这个属性可以在打印时有效--><style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}</style><style>
.tdp
{
border-bottom:1 solid #000000;
border-left:1 solid #000000;
border-right:0 solid #ffffff;
border-top:0 solid #ffffff;
}
.tabp
{
border-color: #000000 #000000 #000000 #000000;
border-style: solid;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.NOPRINT {
font-family:"宋体";
font-size: 9pt;
}</style><script>function QueryString(sName)
{var sSource= String(window.document.location);var sReturn="";var sQUS="?";var sAMP="&";var sEQ="=";var iPos;

iPos= sSource.indexOf(sQUS);var strQuery= sSource.substr(iPos, sSource.length- iPos);var strLCQuery= strQuery.toLowerCase();var strLCName= sName.toLowerCase();

iPos= strLCQuery.indexOf(sQUS+ strLCName+ sEQ);if (iPos==-1)
{
iPos= strLCQuery.indexOf(sAMP+ strLCName+ sEQ);if (iPos==-1)return"";
}

sReturn= strQuery.substr(iPos+ sName.length+2,strQuery.length-(iPos+ sName.length+2));var iPosAMP= sReturn.indexOf(sAMP);if (iPosAMP==-1)return sReturn;else
{
sReturn= sReturn.substr(0, iPosAMP);
}return sReturn;
}var PrintFirst=function(){
window.location.href= window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")+"&PageIndex=1";
}var PrintLast=function(){var last= QueryString('LastPage');
window.location.href= window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")+"&PageIndex="+last;
}var PrintPre=function(){var index= QueryString('PageIndex');if(index>1)
window.location.href= window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")+"&PageIndex="+(index-1);else alert("到头了");
}var PrintNext=function(){var index= parseInt(QueryString('PageIndex'));var last= parseInt(QueryString('LastPage'));if((index+1)<=last)
window.location.href= window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")+"&PageIndex="+(index+1);else alert("到头了");
}//创建按钮var createButton=function(vID,vValue,eventHandler){var div=document.getElementById("div1");var btnButton= document.createElement("INPUT");
btnButton.type="Button";
btnButton.id= vID;
btnButton.value= vValue;
btnButton.onclick= eventHandler;
div.appendChild(btnButton);
}//创建标签var createSpan=function(vID,vValue,eventHandler){var div=document.getElementById("div1");var htmSpan= document.createElement("span");
htmSpan.id= vID;
htmSpan.innerHTML= vValue;if(eventHandler!=null)
htmSpan.onclick= eventHandler;
div.appendChild(htmSpan);
}//按钮事件var print=function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(6,1);
}var directPrint=function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(6,6);
}var PrintSetUp=function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(8,1);
}var PrintReview=function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(7,1);
}

window.onload=function(){
createButton("btn0","打印",print);
createButton("btn1","直接打印",directPrint);
createButton("btn2","页面设置",PrintSetUp);
createButton("btn3","打印预览",PrintReview);
createButton("btn4","首 页",PrintFirst);
createButton("btn5","上一页",PrintPre);
createButton("btn6","下一页",PrintNext);
createButton("btn7","末 页",PrintLast);var index=QueryString('PageIndex');var last= QueryString('LastPage');
createSpan("span0"," 当前第 "+index+"/"+last+" 页 ",null);
}//设置网页打印的页眉页脚为空function pagesetup_null(){var hkey_root,hkey_path,hkey_key;
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";try{var RegWsh=new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
}catch(e){}
}</script></head><body><center class="Noprint"><p><OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT><div id="div1"></div></p></center><div class="page"><table id="Table_01" width="780" height="360" border="0" cellpadding="0" cellspacing="0" background="行程单.JPG"><tr><td width="931" style="position:relative; padding:inherit;"><div id="Layer2" align="center" style="position:absolute;

left:57px; top:98px; width:55px; height:20px; z-index:2;">FEKPO</div><div id="Layer6" style="position:absolute; left:450px; top:72px; width:119px; height:23px; z-index:6;

vertical-align:middle" align="center">一星期内有效</div><div id="Layer9" style="position:absolute; left:95px; top:276px; width:153px; height:24px; z-index:9;"

align="left">7188881131464</div><table width="98%" align="center" runat="server" height="" style="position:absolute; top:134px; left: 62px; width: 686px;"><tr><td width="106" align="left" height="20">北京 FOR</td><td width="54" height="20" align="center">方中信</td><td width="40" height="20" align="center">C10</td><td height="20" width="44" align="center">A级</td><td height="20" width="65" align="center">2008-03-21</td><td height="20" width="34" align="center">09:00</td><td height="20" width="147" align="center">高级/高等</td><td height="20" width="57" align="center">2008-03-21</td><td height="20" width="55" align="center">2008-03-27</td><td height="20" width="40">无任何行李</td></tr></table><div id="Layer10" style="position:absolute; left:98px; top:314px; height:19px; z-index:10; width: 62px;" align="center">086</div><div id="layer9" style="position:absolute; left:247px; top:315px; height:18px; z-index:10; width: 260px;" align="center">纵横天地电子商旅公司</div><div id="layer" align="center" style="position:absolute; left:684px; top:273px; width:63px; height:24px;

z-index:2;">40.00¥</div><div id="layer2" align="left" style="position:absolute; left:203px; top:73px; width:203px; height:20px; z-

index:2;">43453453</div><div id="layer3" style="position:absolute; left:272px; top:281px; height:19px; z-index:10; width: 67px;" align="center">APKS</div><div id="layer4" align="center" style="position:absolute;

left:57px; top:72px; width:55px; height:20px; z-index:2;">方信</div><div id="layer5" align="center" style="position:absolute; left:403px; top:277px; width:55px; height:24px;

z-index:2;">无</div><div id="layer6" align="center" style="position:absolute; left:643px; top:308px; width:85px; height:24px;

z-index:2;">2008-03-21</div><table width="98%" align="center" runat="server" height="" style="position:absolute; top:252px; left: 190px; width: 556px; height: 21px;"><tr><td width="102" align="left" height="20">1000.00¥</td><td width="91" height="20" align="center">90.00¥</td><td height="20" width="90" align="center">70.00¥</td><td height="20" width="100" align="center">40.00¥</td><td height="20" width="149" align="center">1200.00¥</td></tr></table></td></tr></table></div></body></html>
[/Quote]顶一个
luohuayh 2009-11-29
  • 打赏
  • 举报
回复
[Quote=引用 38 楼 pt1314917 的回复:]
JScript code//参考;<%@ Control Language="c#" AutoEventWireup="false" Inherits="FLX.Portal.PageModeTemplate"%><style type="text/css"><!--
.STYLE1 {color: #FF0000}--></style><html><head><title></title><me?-
[/Quote]
能否吧获取数据的那页也贴出来?
luohuayh 2009-11-29
  • 打赏
  • 举报
回复
[Quote=引用 37 楼 luohuayh 的回复:]
有没有一个成熟的,可以实现的可行方法,实在没有我就结贴了!
[/Quote]
能否吧获取数据的那页也贴出来?
pt1314917 2009-11-29
  • 打赏
  • 举报
回复

//参考;
<%@ Control Language="c#" AutoEventWireup="false" Inherits="FLX.Portal.PageModeTemplate" %>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print 这个属性可以在打印时有效-->
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>

<style>
.tdp
{
border-bottom: 1 solid #000000;
border-left: 1 solid #000000;
border-right: 0 solid #ffffff;
border-top: 0 solid #ffffff;
}
.tabp
{
border-color: #000000 #000000 #000000 #000000;
border-style: solid;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.NOPRINT {
font-family: "宋体";
font-size: 9pt;
}
</style>
<script>

function QueryString(sName)
{
var sSource = String(window.document.location);
var sReturn = "";
var sQUS = "?";
var sAMP = "&";
var sEQ = "=";
var iPos;

iPos = sSource.indexOf(sQUS);

var strQuery = sSource.substr(iPos, sSource.length - iPos);
var strLCQuery = strQuery.toLowerCase();
var strLCName = sName.toLowerCase();

iPos = strLCQuery.indexOf(sQUS + strLCName + sEQ);
if (iPos == -1)
{
iPos = strLCQuery.indexOf(sAMP + strLCName + sEQ);
if (iPos == -1)
return "";
}

sReturn = strQuery.substr(iPos + sName.length + 2,strQuery.length-(iPos + sName.length + 2));
var iPosAMP = sReturn.indexOf(sAMP);

if (iPosAMP == -1)
return sReturn;
else
{
sReturn = sReturn.substr(0, iPosAMP);
}
return sReturn;
}


var PrintFirst = function(){
window.location.href = window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")
+"&PageIndex=1";
}

var PrintLast = function(){
var last = QueryString('LastPage');
window.location.href = window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")
+"&PageIndex="+last;
}

var PrintPre = function(){
var index = QueryString('PageIndex');
if(index>1)
window.location.href = window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")
+"&PageIndex="+(index-1);
else alert("到头了");
}

var PrintNext = function(){
var index = parseInt(QueryString('PageIndex'));
var last = parseInt(QueryString('LastPage'));
if((index+1)<=last)
window.location.href = window.location.href
.replace(/\?PageIndex=(\d)*$/g,"").replace(/\?PageIndex=(\d)*&/g,"?").replace(/&PageIndex=(\d)*&/g,"&").replace(/&PageIndex=(\d)*$/g,"")
+"&PageIndex="+(index+1);
else alert("到头了");
}

//创建按钮
var createButton = function(vID,vValue,eventHandler){
var div =document.getElementById("div1");
var btnButton = document.createElement("INPUT");
btnButton.type ="Button";
btnButton.id = vID;
btnButton.value = vValue;
btnButton.onclick = eventHandler;
div.appendChild(btnButton);
}
//创建标签
var createSpan = function(vID,vValue,eventHandler){
var div =document.getElementById("div1");
var htmSpan = document.createElement("span");
htmSpan.id = vID;
htmSpan.innerHTML = vValue;
if(eventHandler != null)
htmSpan.onclick = eventHandler;
div.appendChild(htmSpan);
}
//按钮事件
var print = function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(6,1);
}
var directPrint = function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(6,6);
}
var PrintSetUp = function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(8,1);
}
var PrintReview = function(){
pagesetup_null();
document.all.WebBrowser.ExecWB(7,1);
}

window.onload = function(){
createButton("btn0","打印",print);
createButton("btn1","直接打印",directPrint);
createButton("btn2","页面设置",PrintSetUp);
createButton("btn3","打印预览",PrintReview);
createButton("btn4","首 页",PrintFirst);
createButton("btn5","上一页",PrintPre);
createButton("btn6","下一页",PrintNext);
createButton("btn7","末 页",PrintLast);
var index =QueryString('PageIndex');
var last = QueryString('LastPage');
createSpan("span0"," 当前第 "+index+"/"+last+" 页 ",null);
}
//设置网页打印的页眉页脚为空
function pagesetup_null(){
var hkey_root,hkey_path,hkey_key;
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
}catch(e){}
}
</script>
</head>
<body >
<center class="Noprint" >
<p>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0>
</OBJECT>
<div id="div1">
</div>
</p>
</center>
<div class="page">
<table id="Table_01" width="780" height="360" border="0" cellpadding="0" cellspacing="0" background="行程单.JPG">
<tr><td width="931" style="position:relative; padding:inherit; "><div id="Layer2" align="center" style="position:absolute;

left:57px; top:98px; width:55px; height:20px; z-index:2;">FEKPO</div>
<div id="Layer6" style="position:absolute; left:450px; top:72px; width:119px; height:23px; z-index:6;

vertical-align:middle" align="center">一星期内有效</div>
<div id="Layer9" style="position:absolute; left:95px; top:276px; width:153px; height:24px; z-index:9;"

align="left">7188881131464</div>
<table width="98%" align="center" runat="server" height="" style="position:absolute; top:134px; left: 62px; width: 686px;">
<tr>
<td width="106" align="left" height="20" >北京 FOR </td>
<td width="54" height="20" align="center" >方中信</td>
<td width="40" height="20" align="center" >C10</td>
<td height="20" width="44" align="center" >A级</td>
<td height="20" width="65" align="center" >2008-03-21</td>
<td height="20" width="34" align="center" >09:00</td>
<td height="20" width="147" align="center" >高级/高等</td>
<td height="20" width="57" align="center" >2008-03-21</td>
<td height="20" width="55" align="center" >2008-03-27</td>
<td height="20" width="40" >无任何行李</td>
</tr>
</table>
<div id="Layer10" style="position:absolute; left:98px; top:314px; height:19px; z-index:10; width: 62px;" align="center">086</div>
<div id="layer9" style="position:absolute; left:247px; top:315px; height:18px; z-index:10; width: 260px;" align="center">纵横天地电子商旅公司</div>
<div id="layer" align="center" style="position:absolute; left:684px; top:273px; width:63px; height:24px;

z-index:2;">40.00¥</div>
<div id="layer2" align="left" style="position:absolute; left:203px; top:73px; width:203px; height:20px; z-

index:2;">43453453</div>
<div id="layer3" style="position:absolute; left:272px; top:281px; height:19px; z-index:10; width: 67px;" align="center">APKS</div>
<div id="layer4" align="center" style="position:absolute;

left:57px; top:72px; width:55px; height:20px; z-index:2;">方信</div>
<div id="layer5" align="center" style="position:absolute; left:403px; top:277px; width:55px; height:24px;

z-index:2;">无</div>
<div id="layer6" align="center" style="position:absolute; left:643px; top:308px; width:85px; height:24px;

z-index:2;">2008-03-21</div>
<table width="98%" align="center" runat="server" height="" style="position:absolute; top:252px; left: 190px; width: 556px; height: 21px;">
<tr>
<td width="102" align="left" height="20" >1000.00¥</td>
<td width="91" height="20" align="center" >90.00¥</td>
<td height="20" width="90" align="center" >70.00¥</td>
<td height="20" width="100" align="center" >40.00¥</td>
<td height="20" width="149" align="center" >1200.00¥</td>
</tr>
</table></td></tr>
</table>
</div>

</body>
</html>



luohuayh 2009-11-29
  • 打赏
  • 举报
回复
有没有一个成熟的,可以实现的可行方法,实在没有我就结贴了!
luohuayh 2009-11-28
  • 打赏
  • 举报
回复
人呢?高手呢?
whut0802 2009-11-28
  • 打赏
  • 举报
回复
不知道,学习
luohuayh 2009-11-28
  • 打赏
  • 举报
回复
可惜我自己不会写,会写也不用上论坛求助了!
道光2008 2009-11-28
  • 打赏
  • 举报
回复
js套打?
估计你要自己写一个ocx,调用了
luohuayh 2009-11-27
  • 打赏
  • 举报
回复
[Quote=引用 30 楼 luobingxka 的回复:]
晕,难道我进错区了,都不知道是从哪看到的这篇帖子就回了。实在不好意思,我不熟悉JAVA的,只熟悉C++、C#,其实你能大概看懂你就按照JAVA的方式去实现就好了,你也可以通过拼接字符串的方式输出table。
[/Quote]
= =!没事,不过还是得谢谢你提供的算法。虽然不是JAVA的,但我还是能看懂你的代码思想。
我只相信汗水 2009-11-27
  • 打赏
  • 举报
回复
晕,难道我进错区了,都不知道是从哪看到的这篇帖子就回了。实在不好意思,我不熟悉JAVA的,只熟悉C++、C#,其实你能大概看懂你就按照JAVA的方式去实现就好了,你也可以通过拼接字符串的方式输出table。
加载更多回复(28)

87,917

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧