Click to See Complete Forum and Search --> : external javascript problems


Esm3638
07-03-2003, 11:01 AM
Problem: sometimes our buttons don't show up!

We have multiple screen that all have buttons at the bottom of the page. i.e. page forward. page backward, return.

To make the buttons all the same we developed an external script that contains all of the possible buttons. The script is about 9 kb.

The script works great, with one exception sometimes the buttons do not show up!!

The script start out as 11kb. We shrunk the script down in size and there did not seem to be as many errors. But. we are still getting these errors sometimes. Our customer only use Internet Explorer.

I am not sure if the script is to big or what??
How is an external script loaded? what if there are multiple scripts?



here is the code:

var ctr = 1;
var navTbl = "<table width=600> <tr> <td class='header2'>";
var tranTbl = "<table align='center' border=1 width=300 cellpadding=5 cells
var butnNm = '';
var keyNm = '';
var fnctNm = '';

function createNonTransButtons
(fil,c,en,enn,en1,en1n,b,f,fp,lp,d,r,e,cl,f9,f9n,f10,f10n,f11,f11n,f12,f12

if (c != null){
if (c.toUpperCase() == 'Y'){
butnNm = "DFH_ENTER";
keyNm = "Continue";
fnctNm = "processContinue()";
wrtNTranLn();
}}

if (en != null){
if (en.toUpperCase() == 'Y'){
butnNm = "DFH_ENTER";
keyNm = enn;
fnctNm = "processEnter1()";
wrtNTranLn();
}}

if (b != null){
if (b.toUpperCase() == 'Y'){
butnNm = "DFH_PF7";
keyNm = "Page back";
fnctNm = "processPageBack()";
wrtNTranLn();
}}
ChkforBrk();
if (f != null){
if (f.toUpperCase() == 'Y'){
butnNm = "DFH_PF8";
keyNm = "Page forward";
fnctNm = "processPageFwd()";
wrtNTranLn();
}}
ChkforBrk();
if (lp != null){
if (lp.toUpperCase() == 'Y'){
butnNm = "DFH_PF4";
keyNm = "Last page";
fnctNm = "processLastPage()";
wrtNTranLn();
}}
ChkforBrk();
if (d != null){
if (d.toUpperCase() == 'Y'){
butnNm = "DFH_PF11";
keyNm = "Directory";
fnctNm = "processDirectory()";
}}
ChkforBrk();
//** located here for prop & bop use of directory on the enter key
if (en3 != null){
if (en3.toUpperCase() == 'Y'){
butnNm = "DFH_ENTER";
keyNm = en3n;
fnctNm = "processEnter4()";
wrtNTranLn();
}}
ChkforBrk();
//** located here for prop use of SIP button on the enter key
if (en4 != null){
if (en4.toUpperCase() == 'Y'){
butnNm = "DFH_ENTER";
keyNm = en4n;
fnctNm = "processEnter5()";
wrtNTranLn();
}}
ChkforBrk();
if (f1 != null){
if (f1.toUpperCase() == 'Y'){
butnNm = "DFH_PF1";
keyNm = f1n;
fnctNm = "processF1Function()";
wrtNTranLn();
}}
navTbl += "</td>";
navTbl += "</tr>";
navTbl += "</table>";
navTbl += "<br>";
navTbl += "<br>";
document.write(navTbl);
}
function createTransButtons
(fil, EntInq, cmplt, cmpltrvw, sus, susrvw, clr, tosbk, binder){

tranTbl += "<tr><td align='center' class='grey'> ";
tranTbl += "Transaction";
tranTbl += "<br> ";
if (cmplt != null){
if (cmplt.toUpperCase() == 'Y'){
butnNm = "DFH_ENTER";
keyNm = "Complete";
if (EntInq.toUpperCase() == 'E'){
fnctNm = 'processVerify99(\"E\",this.form)'
}else{
fnctNm = 'processVerify99(\"I\",this.form)'
}
wrtTranLn2();
}}
tranTbl += "</td>";
tranTbl += "</tr>";
tranTbl += "</table>";

document.write(tranTbl);
}
function wrtTranLn2(){
tranTbl += "<input type='button' Name='";
tranTbl += butnNm;
tranTbl += "' value ='";
tranTbl += keyNm;
tranTbl += "' onClick='";
tranTbl += fnctNm;
tranTbl += "'>";
tranTbl += "&nbsp;";
}
function wrtNTranLn(){
navTbl += "<input type='submit' Name='";
navTbl += butnNm;
navTbl += "' value ='";
navTbl += keyNm;
navTbl += "' onClick='";
navTbl += fnctNm;
navTbl += "'>";
navTbl += "&nbsp;";
ctr ++;
}
function wrtNTranLn2(){
navTbl += "<input type='button' Name='";
navTbl += butnNm;
navTbl += "' value ='";
navTbl += keyNm;
navTbl += "' onClick='";
navTbl += fnctNm;
navTbl += "'>";
navTbl += "&nbsp;";
ctr ++;

}

function ChkforBrk(){
if (ctr > '5'){
navTbl += "</td>";
navTbl += "</tr>";
navTbl += "<tr>";
navTbl += "<td class='header2'>";
ctr = 1;
}}



I removed some of the redundent code...


Thanks for your help in advance!

chrismartz
07-04-2003, 09:13 AM
To answer your first question, "no" your script is not too big.

to load an external script put this code in the head of your document. be sure to chang e the name of the .js file to the name and loacation you have it at:

<script language="JavaScript" src="external.js"></script>


If you have multiple scripts be sure not to have the same function name repeated

Esm3638
07-07-2003, 07:34 AM
:D

Thanks for your reply!

We are importing the javascript into our code.
This code is used on hundreds of our pages, but for some reason some of the pages do not load up the script (we are assuming). That is why we thought that the script may be too big to load.

A lot of times the screens we are having problems with the buttons not showing up, are smaller than this external script.

Thanks for your help!!