Calling functions from a .JS file
662905Nov 2 2008 — edited Nov 2 2008Good morning,
I stored my Javascript functions in a .JS file and saved the file in the /i/javascript folder on my APEX server.
In the HTML Header field I put the following code: <strong><script src="#IMAGE_PREFIX#javascript/P9001.js" type="text/javascript"></script></strong>.
In the HTML Body Attribute field I put the following code: <strong>javascript: onLoad='P9001PageLoad()';</strong>
When the page loads I get the error "<em>Object Expected</em>" on Line 21, Char 1. (When I view the source, line 21 is the line with the code from the HTML Body Attribute Field.)
Also, in the source HTML of the page, line 17 has <strong><script src="/i/javascript/P9001.js" type="text/javascript"></script></strong> which I assume is how the APEX engine renders the code I typed into the HTML Header field, so I think that I typed it correctly.
I am including the JS function that I am trying to call, but I do not believe there is a problem with the code. If I put the code into the Header Text Field then the function is called, and runs as expected. I beleive my issue has something to do with the JS files.
function P9001PageLoad() {
// Called on pageload to populate the Select Lists with the values in the
// hidden fields. The Hidden fields are populated by P9001_PROC_PAGELOAD.
var i = 1;
var counter = 0;
for (i=1;i<=8;i++) {
var slst_simp = document.getElementById("P9001_SLST_SIMPQS_Q" + i);
var hidn_simp = document.getElementById("P9001_HIDN_SIMPQS_Q" + i);
if (hidn_simp.value != parseInt(hidn_simp.value)) {
slst_simp.value = null
counter++
}
else {
slst_simp.value = hidn_simp.value
}
}
if (counter <8) {
var i = 1;
var counter = 0;
for (i=1;i<=8;i++) {
var slst_simp = document.getElementById("P9001_SLST_SIMPQS_Q" + i);
var hidn_simp = document.getElementById("P9001_HIDN_SIMPQS_Q" + i);
if (hidn_simp.value != parseInt(hidn_simp.value)) {
slst_simp.style.backgroundColor = "#dd0000"
}
}
}
}
Any advice you can offer in helping me utilizing .JS files would be greatly appreciated! Thank you in advance.
Donald Semensky.