Cep Posted November 23, 2006 Share Posted November 23, 2006 I am getting pretty fed up with Javascript at the moment but maybe someone can point out why my script works perfectly fine when in the head tags of an html file but not when the javascript is in an external .js fileAll the code does is read in the name of my checkbox control, if its true it enables another control (arguement 2) and if not it disables the other control.I just constantly get an "object expected" error on the line where the function is called. I have seen this happen on other code I have used too and its really beginning to get annoying.Here is my script[code]function enable_apply(control, objname) { if (control.checked==true) { objname.disabled = false; } if (control.checked==false) { objname.disabled = true; }}[/code]Here is my HTML call,[code] <input name="editcheck" type="checkbox" onclick="enable_apply(this.form.editcheck, this.form.apply);" /> Enable Apply <br /> <br /> <input name="apply" type="submit" class="input" value="Apply" onclick="this.value='Updating...'; this.disabled=true; this.form.submit();" disabled="disabled"; /> <input name="reset" type="reset" class="input" value="Reset all fields" />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28225-script-works-in-header-but-not-externally/ Share on other sites More sharing options...
Cep Posted November 24, 2006 Author Share Posted November 24, 2006 Anyone? I hate bumping but I can't find the solution :D Quote Link to comment https://forums.phpfreaks.com/topic/28225-script-works-in-header-but-not-externally/#findComment-129532 Share on other sites More sharing options...
fenway Posted November 24, 2006 Share Posted November 24, 2006 Sounds like you're trying to call the function before it is declared. Quote Link to comment https://forums.phpfreaks.com/topic/28225-script-works-in-header-but-not-externally/#findComment-129645 Share on other sites More sharing options...
Cep Posted December 4, 2006 Author Share Posted December 4, 2006 The script tag is in the header pointing to the external javascript and the function is called at the end of the form I take it that is declaring before the call? Quote Link to comment https://forums.phpfreaks.com/topic/28225-script-works-in-header-but-not-externally/#findComment-134746 Share on other sites More sharing options...
tomfmason Posted December 4, 2006 Share Posted December 4, 2006 Can you post a link for the script in question? Quote Link to comment https://forums.phpfreaks.com/topic/28225-script-works-in-header-but-not-externally/#findComment-134925 Share on other sites More sharing options...
Cep Posted December 5, 2006 Author Share Posted December 5, 2006 Not really this is on an internal network but the full script is quoted on my first post. I could post up the entire HTML if that would help but as I say the script is literally just that function in an external js document. Quote Link to comment https://forums.phpfreaks.com/topic/28225-script-works-in-header-but-not-externally/#findComment-135403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.