File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes DHTML elements not getting printed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "DHTML elements not getting printed" Watch "DHTML elements not getting printed" New topic
Author

DHTML elements not getting printed

SrinivasGoud Nawab
Greenhorn

Joined: Oct 06, 2005
Posts: 1
All,

I am experiencing print issue with dynamic html elements.A javascript function is called on body load to populate dynamic html table.The table is not getting printed on print event.

The elements are displayed in the page but not on the printed paper.
Please help me out!!!

Thanks in advance,
Srinivas Nawab

Here is the javascript function to populate the dynamic table:
------------------------------------------------------------------
function addRowToTable()
{
var tbl = document.getElementById('LegSummaryTable');
var cell;
var contents; //variable to hold reference of created component
var row;
var legSummStr="";
var tkt_delimit="^~";//Ticket separator
var fld_delimit="^*";//Field separator
var rowindex;
var tkt_arr;//to hold the split legSummStr values
var fld_arr;//to hold ticket values
//varfld_arr_next;

//The following code inserts column headers if table row size is zero
if(tbl.rows.length == 0)
{
var oTHead = document.createElement("THEAD");

// Declare stock data that would normally be imported from a stock Web site.
var heading = new Array;
heading[0] = "Account#";
heading[1] = "Account Name";
heading[2] = "Prod Code";
heading[3] = "Txn Date";
heading[4] = "Status";
heading[5] = "Debits";
heading[6] = "Credits";
heading[7] = "Ccy";
heading[8] = ""; // to take care of white spaces..
heading[9] = "";
heading[10] = "";

legSummStr=document.forms[0]['PBFMLAT:LEG_SUMM_DTLS'].value;

tbl.appendChild(oTHead);

// Insert a row into the header and set its background color.
row = document.createElement("TR");
row.align="left";
oTHead.appendChild(row);

if(legSummStr != "")
{
for (i=0; i<heading.length; i++)
{
contents = document.createElement("TH");
contents.innerHTML = "<span><FONT class='txt' WEIGHT=bold>"+heading[i]+"</FONT></span>";
row.appendChild(contents);
}
}
row = tbl.insertRow();
for (k=0; k<heading.length; k++)
{
cell=row.insertCell();
contents = document.createElement("HR");
cell.appendChild(contents);
}
}

tkt_arr = legSummStr.split(tkt_delimit);

for(i=0;i<tkt_arr.length-1;i++)
{
fld_arr=tkt_arr[i].split(fld_delimit);

rowindex=tbl.rows.length;
row = tbl.insertRow(rowindex);
var count=fld_arr.length-1;
var legID=fld_arr[0];//Which holds legID

var acc_type=fld_arr[12];
var tkt_id=fld_arr[13];
var minLegDate=fld_arr[14];

for(j=0;j<(fld_arr.length-4);j++)
{
if(fld_arr[j+1] == "Edit")
{
cell = row.insertCell(j);
contents = document.createElement("TD");
contents.id=tbl+i+"field"+j;
contents.innerHTML="<span><FONT style='word-wrap: break-word; width:30;' class='txt' WEIGHT=bold><a href=javascript:winLegEdit("+legID+")>"+fld_arr[j+1]+"</FONT></span>";
}
else if(fld_arr[j+1] == "Delete")
{
cell = row.insertCell(j);
contents = document.createElement("TD");
contents.id=tbl+i+"field"+j;
contents.innerHTML = "<span><FONT class='txt' WEIGHT=bold><a href=javascript:winLegDelete("+legID+")>"+fld_arr[j+1]+"</FONT></span>";
}
else if(fld_arr[j+1] == "View")
{
cell = row.insertCell(j);
contents = document.createElement("TD");
contents.id=tbl+i+"field"+j;
contents.innerHTML = "<span><FONT style='word-wrap: break-word; width:30;' class='txt' COLOR=#000000 WEIGHT=bold><a href=javascript:winTktView('"+legID+"','"+acc_type+"','"+tkt_id+"')>"+fld_arr[j+1]+"</FONT></span>";
}
else
{
cell = row.insertCell(j);
contents = document.createElement("TD");
contents.id=tbl+i+"field"+j;
contents.innerHTML ="<span><FONT style='word-wrap: display: width:40;' class='txt' WEIGHT=bold>"+fld_arr[j+1]+"</FONT></span>";
}
cell.appendChild(contents);
count=count-1;
}//end of inner for loop

if(tkt_id == 2)
{
row = tbl.insertRow();

for (k=0; k<heading.length; k++)
{
cell=row.insertCell();
contents = document.createElement("HR");
cell.appendChild(contents);
}
}

}//end of outer loop

}
-----------------------------------------------------------------------
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DHTML elements not getting printed