#1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2004
    Location
    Cairns, Australia
    Posts
    711
    Rep Power
    22

    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
  3. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1171
    Two things I'm looking at as a potential source of the problem; first, this is not a valid document, which is most likely throwing IE into 'quirks mode', and then anything goes. Secondly, you're trying to access a TD element as if it were a DIV or other block element. I'd wrap whatever you want to hide / show in a DIV and then call that id.

    Also, get rid of the "language" attribute, it's deprecated. Use type instead (script type="text/javascript").

    My slightly edited version of your code fails in FF 3.5.6 (Linux).
    "Seriously, we're not a search engine, we're actual people." ~ ManiacDan

    BookMooch.com : Give books away. Get books you want.
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2004
    Location
    Cairns, Australia
    Posts
    711
    Rep Power
    22
    Thanks for the reply

    The table code above is part of a huge form done in table format not divs.
    I changed the script type as you suggested.

    I tried adding this but agian in IE6 it failed to work:

    <div id="description" style="display:none;">
    <td colspan="2">
    <div id="description">

    <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">Delivery Address 2</span></td>
    <td><div align="left">
    <input name="daddress2" 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>
    <tr>
    <td align="left" class="text"><span class="brown3">State</span></td>
    <td><div align="left">
    <select name="dstate" size="1" class="username">
    <option value="">Choose a State</option>
    <option value='Victoria' >Victoria</option>
    <option value='New South Wales' >New South Wales</option>
    <option value='Queensland' >Queensland</option>
    <option value='South Australia' >South Australia</option>
    <option value='Northern Territory' >Northern Territory</option>
    <option value='Western Australia' >Western Australia</option>
    <option value='Tasmania' >Tasmania</option>
    <option value='ACT' >ACT</option>
    </select>
    </div></td>
    </tr>
    <tr>
    <td align="left" class="text"><span class="brown3">Postcode / Zip</span> </td>
    <td><div align="left">
    <input name="dzip" type="text" class="username" value="" size="12" maxlength="10" />
    </div></td>
    </tr>
    </table></div></td>
    </div>

    Any ideas?
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2004
    Location
    Cairns, Australia
    Posts
    711
    Rep Power
    22
    Got it sorted

    I had a meta name called "description". I renamed the id="description" within the body to something else.

    Thanks for your assistance

    Comments on this post

    • lnxgeek agrees : Thanks for following up!
    Last edited by adammc; January 27th, 2010 at 04:56 PM.

IMN logo majestic logo threadwatch logo seochat tools logo