Help with javascript code for IE6

Hi guys,

the following code (radio button) does not show / hide div as done in Firefix /IE8

Is there any way I can get it to work?
Or maybe pure css?

<script language="javascript">

function show(nam) {
	if(nam == 'yes') {
		
		document.getElementById('description').style.display = 'none';
		
		
	} else  {
		
		document.getElementById('description').style.display = '';
	}

}
</script>
			
			
		
			
<tr>
	<td colspan="3" height="20" align="center"><span class="brown3"><STRONG>Same as above? </STRONG></span>
	<input type="radio" name="sameaddress" value="Yes" checked onclick="return show('yes');">Yes
	<input type="radio" name="sameaddress" value="No" onclick="return show('no');">No</td>
</tr>

<tr><td colspan="2" height="20"></td></tr>


	<tr>
	<td colspan="2" height="80" id="description" style="display:none;">
	<table width="100%" align="left" cellpadding="3" class="infobox" >
      <tr>
        <td align="left" class="text"><span class="brown3">Delivery Name</span></td>
        <td><div align="left">
            <input name="dname" type="text" class="username" value="" size="35" />
        </div></td>
      </tr>
      <tr>
        <td align="left" class="text"><span class="brown3">Delivery Address</span></td>
        <td><div align="left">
            <input name="daddress" type="text" class="username" value="" size="35" />
        </div></td>
      </tr>
     
      <tr>
        <td align="left" class="text"><span class="brown3">City</span></td>
        <td><div align="left">
            <input name="dcity" type="text" class="username" value="" size="35" />
        </div></td>
      </tr>
    
          </table></td></tr>

It may have something to do with using tables, but try using a “name” as well as the “id”.

thanks for the reply, tried adding a ‘name’ to the td cell. didnt work :frowning:

Can anyone pleeeeease help?

What browsers are you having trouble with? I’ve found that that above code b itself has trouble, but when you wrap the code inside table tags, that it works fine.

Hi Paul,

IE6, I have had quite a few customers complaining that it didnt work.

IE6 is dead and buried now. Even Microsoft says that you shouldn’t be using it.

When things get tricky for IE6, you can just use the HTML/CSS design that your design starts from (yours does work in a non-scripted environment, right? It’s called progressive enhancement) and use conditional comments to apply scripting to IE when it’s greater than IE6

However - I have pulled down IETester and confirmed that your above code when wrapped in a table does work in IE6.

Further assistance will most likely involve access to a real-live web page that’s up online.

You appear to be right, Itested this code above only wrapped in a table and it does work. However when used with existing page it doesnt.

Could a style sheet be causing this to not work?

td {
font-family: Tahoma, Arial, Verdana, Helvetica, sans-serif; font-size:10px; color:#715C55; line-height:11px; text-decoration:none; font-weight:normal;
}

or another reference overriding the display (none)?

We would need to be able to take a look at the existing page itself, to discover what else is causing the problem.

try this one:
url removed

Tried it in IE tester and ‘deliver address’ shid/show fields wont work.

Thanks. I see that you have a meta name called “description”. IE also includes these named elements in its id search. Crazy, but there you go.

Either remove the meta description, or rename the id=“description” within the body to something else.

OMG! Whooooo Hooo!
That was it!

Thank you soooooo much, I was going a little crazy there :slight_smile:

Too true, IE’s bugs does that to people.

Congrats.