/    Sign up×
Community /Pin to ProfileBookmark

Works in Firefox, not in IE

Hi,

I’m using the following to toggle rows in a form:

[CODE]
function toggleDatePref()
{
var block1 = document.getElementById(“entrynotice”);
var block2 = document.getElementById(“datepref”);
var block3 = document.getElementById(“timepref”);
var block4 = document.getElementById(“athome”);
var determinant = document.getElementById(“presentforservice”);
if(determinant.getValue() == “Yes”)
{
block1.style.display = “none”;
block2.style.display = “table-row”;
block3.style.display = “table-row”;
block4.style.display = “table-row”;
}
else
{
block1.style.display = “table-row”;
block2.style.display = “none”;
block3.style.display = “none”;
block4.style.display = “none”;
}
}

toggleDatePref();
[/CODE]

In the code above, “presentforservice” is the id of a select box containing the values “Yes” and “No”. Firefox uses this script just fine, but IE gives me the following error:

[QUOTE]

Line: 313
Char: 2
Error?bject doesn’t support this property or method
Code: 0
[URL excluded from this post for security]

[/QUOTE]

Is this a problem with the way that IE works with DOM? What’s going on?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 01.2007 — [I]getValue()[/I] is Java not JavaScript and IE also does not support "table-row"
Copy linkTweet thisAlerts:
@jsauveauthorOct 01.2007 — Aha! That makes sense. Is there a javascript equivalent? And why the heck would it work in Firefox, but not IE?
Copy linkTweet thisAlerts:
@FangOct 01.2007 — if(determinant.value == "Yes")
getValue() does not work in JavaScript
Copy linkTweet thisAlerts:
@jsauveauthorOct 01.2007 — Got it. And thank you.

However, I changed determinant.getValue() to determinant.value, but am still getting the same error.

As far as table-row not being compatible with IE, can you suggest an alternative? "inline" maybe?
Copy linkTweet thisAlerts:
@WebnerdOct 01.2007 — 
"presentforservice" is the id of a select box containing the valu
[/quote]


Therefore:
<i>
</i>determinant.options[determinant.selectedIndex].value

is the correct syntax
Copy linkTweet thisAlerts:
@FangOct 02.2007 — [I]determinant.value[/I] does work with an id
×

Success!

Help @jsauve 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.7,
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,
)...