Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE does not recognized display attribute? 1

Status
Not open for further replies.

xiaoleiqq

Programmer
Aug 30, 2006
43
US
Hi,
my intent is to switch content around by the dropdown box,

here is the code:
...
<div style="display:none" id="DD">...</div>
...

and have a js which check for this id, and make necessary changes,here is the code:

if (document.formname.selectionname.value== "DD"){
document.getElementById('DD').style.display ='inline';
document.getElementById('EE').style.display = 'none';
}

ok, it does not work with IE, but it work with FireFox...
FF rocks....-___-'

 
Since you're changing the display of a <div>, why not use

document.getElementById('DD').display='block';

instead? If you want inline display, make the div into a span.

However, since setting a div to display inline works fine with my version of IE, I'd guess you have an error somewhere else, or you didn't copy and paste the actual code from your page as the example. Do you get a little yellow triangle in the status line when your code runs? Are there any errors in the Javascript console in Firefox when the code runs?

Lee
 
[offtopic]Hi there, Lee![/offtopic]
 
Hello. Just been lazy for a while, haven't taken the time to stop by for very long, if at all. :)# I've still been whacking away at Javascript, mainly server side, though.

Lee
 
Thanks for your help~~

Here is the rewrite version of my code, I make it shorter to read, and It shows the problem, I do change the display to block and try with
document.getElementById('DD').display='block';
or set to span,

but unfortunately It still won't like me




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>no title</title>
<script type="text/javascript">
function change(){
var format = document.inputform.Dformat;
if (format.value == "Decimal Degrees"){
document.getElementById('DD').style.display = 'block';
document.getElementById('DMS').style.display = 'none';
}
if (format.value == "Degrees Minutes Seconds"){
document.getElementById('DD').style.display = 'none';
document.getElementById('DMS').style.display = 'block';
}
}
</script>
</head>
<p>

<form action="./cgi-bin/order.cgi" method="post" enctype="application/x- name="inputform" id="inputform">
<label>Select a degree format:
<select name="Dformat" onfocus="change();" onchange="change();">
<option selected="selected">Decimal Degrees</option>
<option>Degrees Minutes Seconds</option>
</select>
</label>
<br /><br />
<div style="display:block" id="DD">
<b>Decimal Degrees</b><br />
Examples:<br>
DD selected.
</div>

<div style="display:none" id="DMS"><b>Degrees, Minutes, And Seconds</b><br>
Examples:<br>
DMS selected.
</div>

</form>
<p>&nbsp;</p>
</body>
</html>
 
You need to assign value attribute to the options. In ff, if no value is set, the text is taken as the value client-side; and server-side as well in the sense that it will be posted back to server. Not so in ie. You should set the value attribute.
[tt]
<select name="Dformat" onfocus="change();" onchange="change();">
<option value="Decimal Degrees" selected="selected">Decimal Degrees</option>
<option value="Degrees Minutes Seconds">Degrees Minutes Seconds</option>
</select>
[/tt]
In any case, with value is of better control. As an aside, I would spare the onfocus handling.

 
Thanks a lot tsuji,

Here is another question about controlling refresh process,

After I select DMS option, and hit the refresh button, It will reset the data content to default(that is, the DD format input), but the option choice is still remain DMS.

Any suggestion on how should I solve this problem?

Thanks in advance...ORZ
 
I tried to reproduce the phenomenon. If the page is of htm extension, it seems that happens. To ensure consistencc, I would add simply the onload line in the script section.
[tt]
window.onload=change;
[/tt]
That seems to take care of it. With an asp page, it seems not happening.
 
Thanks,

It is html extension, I add the your line after load the body and it seem working fine.

Again, appreciate your help greatly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top