Jump to content

Recommended Posts

First I have little knowledge of JS.

 

The code below is a very small part of a large program and simply  displays  some options when the header is clicked and closes when double clicked.

 

Problem

On loading (including going to the next display page ) Internet explorer renders the whole page and shows ALL of the options and only once the whole page is loaded it then hides all of the options and only displays the headers... not at all desireable.

 

Is there a way to hide elements before they are displayed ?

 

Very little hair left so any help is greatly appreciated.

 

 

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function HideGender(){
var table = document.getElementById("GENDER");
table.style.display = 'none';
}

function DisplayGender(){
var row = document.getElementById("GENDER");
row.style.display = '';
}
</script>
</head>
<body onload="HideGender()">
<table width="180" border="0" cellspacing="0" bgcolor="#FFFFFF" >
  <form name="options" method="get" id="shapes" style="display: inline; margin: 0;" >
    <tr>
      <td><a href="#"onclick="DisplayGender()"   ondblclick="HideGender()" rel="nofollow" ><strong class="MaroonText"><em>Gender</em></strong></a></td>
    </tr>
    <tr  id="GENDER" >
      <td height="40"><fieldset class="Blu_text">
        <div align="left" >
          <!-- Male -->
          <input name="Gender_Option"  id="go1"type="radio" value="1"  onclick="form.submit()"/>
          <label for="go1">Men's </label>
          <br />
          <!-- Female -->
          <input name="Gender_Option"  id="go2" type="radio" value="2" onclick="form.submit()"/>
          <label for="go2">Women's </label>
          <br />
          <!-- Kids -->
          <input name="Gender_Option"  id="go3"type="radio" value="3"  onclick="form.submit()"/>
          <label for="go3">Kids </label>
          <br />
          <!-- All genders-->
          <input name="Gender_Option" id="go4" type="radio" value="4" <?php if($_SESSION[Gender_Option] == "4" ){echo 'checked';}else{echo '';}?> onclick="form.submit()"/>
          <label for="go4">Show All </label>
        </div>
      </fieldset></td>
    </tr>
  </form>
</table>
</body>

Link to comment
https://forums.phpfreaks.com/topic/241374-help-with-very-basic-js-and-ie/
Share on other sites

oops sorry..I was mixing visibility and display.

 

<head>
<style type='text/css'>
#GENDER {
  display : none;
}
</style>
<script type="text/javascript">
function HideGender(){
var table = document.getElementById("GENDER");
table.style.display = 'none';
}

function DisplayGender(){
var row = document.getElementById("GENDER");
row.style.display = 'inline'; // or 'block' depending on the rest of your layout/preference
}
</script>
</head>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.