Click here to Skip to main content
15,557,821 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<pre lang="Javascript"><pre>var xmlcodebar="";

---
---

function runonload(){
	code for print preparation
	-------
	-------
	fnQrCode(dealref,sterlingQR, deliveryType); //this function for qr code generation 
	xmlcodebar = "data:image/png;base64,"+xmlcodebar;
	footer11 = '<td width="100%"><img src='+xmlcodebar+' align="center" width="750" height="150"></td>';
	footer12 = '</tr></table>';

	fnBuildBody(strRows,strPrintData, Number(strPageLength),footer1,footer2, footer3, footer4, footer5, footer6, footer7, footer8,footer9, footer10, footer11, footer12); //this function for printing

	-------
	--------
}


function fnQrCode(dealref,sterlingQR,deliType){
	var data =sterlingQR+";"+dealref+"$;"+deliType;
	var strQueryString = "hdnOptPage=QRCODE&DATA="+data;
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Browser doesn't supports Http Request");
		return;
	}
	var url = "<%=CONTROLSERV_TFROUT%>"+"?"+strQueryString;
	xmlHttp.onreadystatechange = stateBarcode;
	xmlHttp.open("POST",url,false);
	xmlHttp.send(); 
}

function stateBarcode() {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
	  if(xmlHttp.status == 404 || xmlHttp.status == 500){      	
 	   	   alert("Problem occured at server. Please try again.");
				window.event.returnValue=false;
					return;
      } else if (xmlHttp.status == 200) {
    	  xmlcodebar = xmlHttp.responseText;    
      }        
    }
}

function GetXmlHttpObject() {
	    var objXMLHttp = null;
	    //check whether browser supports HttpRequest
	    if (window.XMLHttpRequest) {
	        objXMLHttp = new XMLHttpRequest();
	    } else {
	        if (window.ActiveXObject) {            
	            objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	        }
	    }
	    return objXMLHttp;
}


What I have tried:

I am facing some unidentified issue. please any one help me to sort out.

problem is when runonload() function runs, we will get print but I am getting duplicate prints (with same data). but this function executes one time (logs in this function write one time) but fnQrCode() & fnBuildBody() calling twice (logs in these function writes twice and getting prints twice). there is no loop for second time. Below is my code snippet
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900