/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] IE Only "Object Not Found" Errors – is it ignoring my script?

I’m fairly new to JavaScript and always find myself struggling with IE problems. The following code works in FireFox, but gives the old “Object Not Found” error in IE:

[code=php]<script type=”application/javascript”>
function disableAddress (inputElement, setting)
{
var formElements = inputElement.form.elements;

formElements[“address_ok”].disabled=setting;
formElements[“address_change”].disabled=setting;
formElements[“street”].disabled=setting;
formElements[“city”].disabled=setting;
formElements[“state”].disabled=setting;
formElements[“zip”].disabled=setting;
}
</script>[/code]

It’s called when you click a radio button:

[code=html]<input type=”radio” name=”election” value=”Pay-Out” onclick=”disableAddress(this, false);” />

or

<input type=”radio” name=”election” value=”Reinvest” onclick=”disableAddress(this, true);” />
[/code]

Clicking any of the radio buttons, regardless of the parameters in them, gives the error.

As far as I can tell, it’s because IE isn’t finding the script, which is defined a few lines above the form containing the radio. If I paste the code directly into the onclick event in the radio’s input tag, it works. However, I keep having the same problem on other pages I am building and I want to know the right way to get this to work.

Other notes – the script block is defined in the body of the page, not the head – the site is complex and driven by lots (and lots) of PHP, so it’s not especially practical to stick it in the head. It should work anyway, shouldn’t it? I have also tried to include such scripts in external files with a script scr= type tag and that has the same results – FF good, IE bad.

Thanks,
Frank

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 03.2008 — Unfortunately IE does not support the mime type [I]application/javascript[/I]. IE ignores this script.

Use the obsolete and unregistered mime type [I]text/javascript[/I].
Copy linkTweet thisAlerts:
@FrankTheTankauthorJul 03.2008 — It's official. I'm an idiot. You don't want to know how much time I wasted because of this...

Thanks so much. [B]Fang[/B] is my hero. Mark this puppy resolved.

Frank
×

Success!

Help @FrankTheTank spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...