Jump to content

Script works in header but not externally?


Cep

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.