JS Function works on internal script but not external

  • ShawnO
  • Newbie
  • Newbie
  • ShawnO
  • Posts: 6

Post 3+ Months Ago

Hello, I was working on another problem in another thread and that is fixed nicely now. But, what I am doing is trying to clean up my main page by moving the new script into an external script file. This file is setup with a link and I know already works because there are other functions in this external script that are working. Essentially, I did a final test on my new function (worked fine), cut the function out of the main page and pasted it into the external page. Now it doesn't work. If I put it back into the main page again, it works fine... What am I doing wrong?? Here is the link that I am using to call the script:
Code: [ Select ]
<a href="javascript: void CheckEnterpriseName();">Check Name</a>


and here is the link to the external script:
Code: [ Select ]
<script language="javascript1.2" src="validateBlue.js"></script>

In an attempt to make it work, I changed the regular 'javascript' to 'javascript1.2'. Didn't think it would matter either way. The functions that I am calling are:

Code: [ Select ]
function checkEnterpriseName() {
        alert ("Moved over");
    var ent_name = document.bluetie_form.enterprise.value;
    if (!(ent_name) || ent_name == " " || ent_name == "." ) {
        alert ("Please enter a name in the Enterpise field");
        return (false);
        }
    else {
        myNewWindow = window.open('https://www.bluetie.com/ent_lookup.asp?ename=' + ent_name + '&showAlt=True','zoomwindow','width=400, height=250, top=300, left=250, toolbar=0, menubar=0, location=0, status=0, scrollbars=0, resizable=0');
        checkWindow = setTimeout('checkWindowOpen()', 1000);
        }
}
function checkWindowOpen() {
    if (myNewWindow.closed) {
        temp_confirm = confirm ("Click OK if the name is available!");
        if (temp_confirm) { document.bluetie_form.ent_check.value=1; }
        else { document.bluetie_form.ent_check.value=0; }
        }
    else { setTimeout("checkWindowOpen()", 1000); }
    }
  1. function checkEnterpriseName() {
  2.         alert ("Moved over");
  3.     var ent_name = document.bluetie_form.enterprise.value;
  4.     if (!(ent_name) || ent_name == " " || ent_name == "." ) {
  5.         alert ("Please enter a name in the Enterpise field");
  6.         return (false);
  7.         }
  8.     else {
  9.         myNewWindow = window.open('https://www.bluetie.com/ent_lookup.asp?ename=' + ent_name + '&showAlt=True','zoomwindow','width=400, height=250, top=300, left=250, toolbar=0, menubar=0, location=0, status=0, scrollbars=0, resizable=0');
  10.         checkWindow = setTimeout('checkWindowOpen()', 1000);
  11.         }
  12. }
  13. function checkWindowOpen() {
  14.     if (myNewWindow.closed) {
  15.         temp_confirm = confirm ("Click OK if the name is available!");
  16.         if (temp_confirm) { document.bluetie_form.ent_check.value=1; }
  17.         else { document.bluetie_form.ent_check.value=0; }
  18.         }
  19.     else { setTimeout("checkWindowOpen()", 1000); }
  20.     }


Any help would be appreciated!!! Thanks!
Shawn
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Might provide a quicker solution if you copied how you had it originally in it's entirety.
  • ShawnO
  • Newbie
  • Newbie
  • ShawnO
  • Posts: 6

Post 3+ Months Ago

The functions are original, except when on the main page, they are put in with
Code: [ Select ]
<script language="javascript"> .... insert functions pasted above .... </script>


On the external .js file, there isn't a script tag, it is just all the functions.

Hope that helps a little better!!

Shawn
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Try:
Code: [ Select ]
<a HREF="#" onClick="CheckEnterpriseName();">Check Name</a>


make sure the SRC in your script call is correct

Code: [ Select ]
<script LANGUAGE="JavaScript" TYPE="text/javascript" SRC="validateBlue.js"></script>


Throw an alert("hello world"); somewhere at the beginning of your function to make sure it's being called at all. If it is, then it's an error in your script.

Make sure you clear your cache and all that too, sometimes IE caches and won't release it... Hold CTRL when you click refresh to force IE to retrive new versions from the server.

.c
  • ShawnO
  • Newbie
  • Newbie
  • ShawnO
  • Posts: 6

Post 3+ Months Ago

Thanks for the info...

I did the alert box and it wasn't even being passed into the external script...

Found the error though when going through it - a misplaced ( instead of a { and it flipped out the whole script!!

Thanks!

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 72 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.