Hi all,
I'm tyring to create an stylesheet that generates a purchase order and I am using a mix of XSL and JavaScript to control the pagination. I have an external JavaScript file (PrintedForm.
js, see below) that contains a few simple functions and two variables (a row count and a maximum number of lines on the page). I increment the row count using a JavaScript function each time a <TR> is created and the row count variable in the external JavaScript file is correctly updated:
<TR></TR>
<SCRIPT LANGUAGE="JavaScript">
incRowCount();
</SCRIPT>
I would like to test the row count value in the XSL, but I do not know how to execute the getRowCount() function and store that value in an XSL variable. I tried this:
<xsl:variable name="curRowCount" select="JavaScript
:getRowCount();"/>
but I get an error saying that "JavaScript must be a name space", and I see why I got this error. I also tried this:
<xsl:variable name="curRowCount">
<SCRIPT LANGUAGE="JavaScript">
getRowCount();
</SCRIPT>
</xsl:variable>
but this just returns the string "getRowCount();" and does not execute the function. Does anyone know a way to set that XSL variable using the JavaScript function or is there another way around it?
Thanks,
Tom
================================================== ========
PrintedForm.
js:
// Create global variables here
var rowCount = 0;
var bodyLength = 0;
// Sets the number of rows in the body of the form
function setBodyLength(param)
{
bodyLength = param;
}
// Initializes the row count to zero
function initRowCount()
{
rowCount = 0;
}
function getRowCount()
{
return rowCount;
}
function incRowCount()
{
rowCount++;
}
function incRowCountByAmt(incBy)
{
rowCount += incBy;
}
function addBlankRows()
{
var diff = bodyLength - rowCount;
document.write('<TABLE BORDER="0">');
var i;
for(i = 0; i < diff; i++)
{
document.write('<TR><TD CLASS="TDCELL"><TD></TR>');
rowCount++;
}
document.write("</TABLE>");
}
function showRowCount()
{
document.write("The row count is now "+rowCount);