/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Not working in IE

Can anyone tell me why this isn’t working in IE.

[CODE]
function cmdHide(x){
var a = “Row” + x
var b = “Image” + x
if(document.getElementById(a).style.display==”none”){
document.getElementById(a).style.display=”table-row”
document.getElementById(b).src=”/Images/up_arrow.gif”
}
else{
document.getElementById(a).style.display=”none”
document.getElementById(b).src=”/Images/down_arrow.gif”
}
}
[/CODE]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@mrhooApr 23.2007 — document.getElementById(a).style.display="table-row"

one of IE's stumbles is css display properties.

you are pretty much stuck with none, block, inline and inherit.

You should be able to set an element.style.display='' to remove the 'none' and use whatever the browser has for a default table display.

Just don't override the default with tr{display:none} in a style sheet.
Copy linkTweet thisAlerts:
@vijirubaApr 23.2007 — [CODE]
if(document.getElementById(a).style.display=="none"){
[COLOR="Blue"]document.getElementById(a).style.display=""[/COLOR]
document.getElementById(b).src="/Images/up_arrow.gif"
}
[/CODE]
Copy linkTweet thisAlerts:
@rootApr 23.2007 — Also, it would be more tidy if you only requested the document element once...

function cmdHide(x){

var a = "Row" + x;

var b = "Image" + x;

da=document.getElementById(a);

db=document.getElementById(b);

if(da.style.display=="none"){

da.style.display="";

db.src="/Images/up_arrow.gif";

}else{...

// do something else...

}


}

is allot easier to read, you grab all the data you need in one object variable and then access the properties far quicker as your not having the function search the document nodes which people dont understand that in a simple form can be as many as 140 objects... so looking on a document.body could be thousands of nodes to search, speed up things by creating an object reference to the item directly or use direct references to the document element you want to grab or make a change in.
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 23.2007 — Thanks guys, I was able to get it working.
×

Success!

Help @nbcrockett 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 2.22,
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: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,

tipper: @neststayhome,
tipped: article
amount: 1000 SATS,
)...