Jump to content

Script works in header but not externally?


Recommended Posts

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 file

All 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"; />&nbsp;&nbsp;<input name="reset" type="reset" class="input" value="Reset all fields" />
[/code]     
  • 2 weeks later...
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.