alert() window does not work from external JS file

Giganews Newsgroups
Subject: alert() window does not work from external JS file
Posted by:  pnber…@gmail.com
Date: Thu, 29 Nov 2007

Hello,

I was doing some testing with a JavaScript file that is loaded as an
external library. I like to use alert() windows to test or see values
as I do development work but I found that when the alert() function is
used from the external library file it doesn't work. But when I moved
the same code back into the <head></head> section of my web page the
alert() windows did work. What is going on here? (I'm using firefox
2.0.0.8)

Paul

Original section of my .php web page where the alert windows didn't
work:
snip------------------------------------>
print '<html>';
print '<head>';
#JavaScript code and CSS formatting to highlight the "Update row"
print '<script src="tr_javascript.js" type="text/javascript"></
script>';
print '<link rel="stylesheet" type="text/css"
href="tr_stylsheet.css">';
print '</head>';
snip------------------------------------>

tr_javascript.js:
/* JavaScript for Transaction form
*  selectRow function borrowed from comp.lang.javascript usergroup
*  causes background and font color to change when row is selected.
*/
//objCurrentRowSelected is a 'object HTML TableRowElement'
var objCurrentRowSelected = null;
function selectRow(objRow,rownum) {
    if (objRow != objCurrentRowSelected) { //clicked row != row already
highlighted
        if (objCurrentRowSelected) { //clicked row is not null
            objCurrentRowSelected.className = ""; //current row is de-
highlighted
            }
        //new row is highlighted
        objCurrentRowSelected = objRow;
        objCurrentRowSelected.className = "selected";
        }

    //Statements for identifying which row was selected and passing the
value to php
    //via the value of a hidden form field
    var row_number = document.getElementById("row_number");
    row_number.value = rownum;
        alert(rownum);
    }

Replies