SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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?

    Code:
    <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>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,252
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    It may have something to do with using tables, but try using a "name" as well as the "id".

  3. #3
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply, tried adding a 'name' to the td cell. didnt work

    Can anyone pleeeeease help?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Paul,

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

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)?

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    We would need to be able to take a look at the existing page itself, to discover what else is causing the problem.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this one:
    url removed

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

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by adammc View Post
    try this one:
    http://www.ecowoodentoys.com.au/test&#37;20ie/test.html

    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #11
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OMG! Whooooo Hooo!
    That was it!

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

  12. #12
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Too true, IE's bugs does that to people.

    Congrats.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •