Abby Lee<ab*******@hotmail.com> wrote in message news:<ui***************************@news.ks.uiuc.e du>...
Another issue...there is a third function called subtotal that adds all the
line totals. subtotal does not work at all.
Ok, I have developed a debug function that puts up a popup window
which I can write debug information to.
Here, I am enclosing a copy of the html file with some examples and
the debug code. Just copy all the code between the script tags and
insert
<script>
// Open the debug window and display debug information
// passing false suppresses all debug information and
// the debug window.
debug(true);
</script>
after the <body> statment.
I used this code to find out that when you looked at 3.00 to determine
if it was an integer, the code was returning false.
Robert
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>javascript debug routines and tester</title>
<script type="text/javascript">
// Popup the debug window.
// You need to have enabled popup windows
// --------------------
function debug(myDebugMode) {
var theMode = myDebugMode;
var popupOk = true;
if (theMode == true)
{
var myWindowName =
document.URL.substr(document.URL.lastIndexOf("/")+1);
var thePosition = myWindowName.indexOf(".");
if (thePosition > 0)
{ myWindowName = myWindowName.substr(0,thePosition); }
myWindowName = myWindowName.replace(/%20/g,"")
// Get rid of special characters because IE won't accept them
myWindowName =
myWindowName.match(/[a-zA-Z0-9]/g).join("");
var documentContent = "javascript
:" +
"if (!document.getElementById('present') )" +
"{" +
"document.open();" +
"document.writeln(" +
'\"<!DOCTYPE HTML PUBLIC \'-//W3C//DTD HTML ' +
'4.01 Transitional//EN\'>' +
"<html>" +
"<head>" +
"<title>Window " + myWindowName + "<\/title>" +
"<style type='text/css'>" +
"div p {margin: 0px;}" +
"<\/style>" +
"<\/head>" +
"<body id='present'>" +
"<div id='debugdiv'>" +
"The debug information that follows was generated on " +
Date() + "<br> <\/p>" +
"<\/div>" +
"<\/body>" +
"<\/html>" + "\");" +
"document.close();" +
"} " +
"else" +
"{" +
"addOn('\\xA0');" +
"var myData = 'The debug information " +
"that follows was generated on ' +" +
"Date();" +
"addOn(myData);" +
"addOn('\\xA0');" +
"}" +
"function addOn (myData) " +
"{ " +
"var node = document.getElementById('debugdiv');" +
"var myPara = document.createElement('P');" +
"node.appendChild(myPara);" +
"myPara.appendChild(document.createTextNode( myData));" +
"}";
try
{
debug.newWindow = window.open(
documentContent,
myWindowName,
"scrollbars,resizable,location,width=700,height=50 0");
}
catch(e)
{
myWindowName = "debug";
debug.newWindow = window.open(
documentContent,myWindowName);
}
}
// Example invocation & print:
// debug.dump(document,'document');
// --------------------
function dump(obj, obj_name)
{
if (theMode == true )
{
debug.out('In DumpProperties. obj=' + obj_name);
for (var i in obj)
{
try
{ debug.out(obj_name + "." + i + " = " + obj[i]); }
catch(e)
{ debug.out("Error writing out structure. Was " +
e + " for " + i); }
}
}
}
debug.dump = dump;
// --------------------
function dumpSorted(obj, obj_name)
{
var i;
var sorted = [ ];
var objCount = 0;
if (theMode == true )
{
debug.out('In DumpProperties. obj=' + obj_name);
for (i in obj)
{
sorted[objCount++] = i;
}
sorted.sort();
for ( i=0; i <sorted.length; i++)
{
try
{ debug.out(obj_name + "." + sorted[i] + " = " +
obj[sorted[i]]); }
catch(e)
{ debug.out("Error writing out structure. Was " +
i + " for " + sorted[i]); }
}
} // if we are debugging.
} // of dumpSorted
debug.dumpSorted = dumpSorted;
// --------------------
function out(obj)
{
var theString = "" + obj;
if (theMode == true )
{
theString = theString.replace(/ /g, "\xA0");
add(debug.newWindow,theString);
}
} // of out
debug.out = out;
// --------------------
function add(win,obj)
{
var node;
if (popupOk == true)
{
try
{ node = win.document.getElementById("debugdiv"); }
catch(e)
{
alert("Please wait a moment then press enter." +
"We are waiting for the popup window to " +
"complete processing.");
try
{ node = win.document.getElementById("debugdiv"); }
catch(e)
{
popupOk = false;
alert("Debugging is disabled." +
"Please ensure that popup windows" +
" are enabled the reload this page.");
return;
}
}
var myPara = win.document.createElement("P");
node.appendChild(myPara);
myPara.appendChild(win.document.createTextNode("" + obj));
}
} // end of add
} // end of debug
</SCRIPT>
</head>
<body>
<script>
var test = {a:1, c:3, b:2};
var testBoolean = true;
// Open the debug window and display debug information
// passing false suppresses all debug information and
// the debug window.
debug(true);
debug.dump(test,"test");
debug.out("display the test object in sorted form");
debug.dumpSorted(test,"test");
debug.out(testBoolean);
debug.out("<b>&<\/b>");
var myString = "abcDEF Ghi~123~ *&^ end";
debug.out("myString = " + myString +
" compressed: " +
escape(myString.match(/[a-zA-Z0-9]/g).join("") ) );
debug.out(
"Display three spaces between words.");
</script>
<p>Debug routines and testing.</p>
</body>
</html>