Jump to content

Hide div


waynew

Recommended Posts

Hi, I have the following JS to hide and show a specific div on a contact form. It works in Firefox, but unfortunately; it fails to do anything in IE7. The functions are called when the user clicks on a specific list item.

 

Any help would be greatly appreciated.

 

// JavaScript Document
var browserType;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}
function hide() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("secondborrowerdiv")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("secondborrowerdiv")');
  else
     document.poppedLayer =   
        eval('document.layers["secondborrowerdiv"]');
  document.poppedLayer.style.visibility = "hidden";
}
function show() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("secondborrowerdiv")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("secondborrowerdiv")');
  else
     document.poppedLayer = 
         eval('document.layers["secondborrowerdiv"]');
  document.poppedLayer.style.visibility = "visible";
}

Link to comment
Share on other sites

Hi, thanks for the reply. I tried that but unfortunately there's not a sign of life in IE7. Works perfectly in FF2.

 

// JavaScript Document
var browserType;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}
function hide() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("secondborrowerdiv")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("secondborrowerdiv")');
  else
     document.poppedLayer =   
        eval('document.layers["secondborrowerdiv"]');
  document.poppedLayer.style.display = "none";
}
function show() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("secondborrowerdiv")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("secondborrowerdiv")');
  else
     document.poppedLayer = 
         eval('document.layers["secondborrowerdiv"]');
  document.poppedLayer.style.display = "block";
}

Link to comment
Share on other sites

Btw, here's my HTML:

 

<select class="border" id="life" name="life" title="Please select Single Life or Joint Life" size="1">
          <option selected="selected" value="" onClick="showdiv('secondborrowerdiv)">-</option>
          <option value="single" onClick="hidediv('secondborrowerdiv)">Single Life</option>
          <option value="joint" onClick="showdiv('secondborrowerdiv)">Joint Life</option>
      </select>

 

Please note that my JS now looks like:

 

function hidediv(id) 	{document.getElementById(id).style.display = 'none';}    
function showdiv(id) 	{document.getElementById(id).style.display = 'block';}

 

And that it works in FF.

Link to comment
Share on other sites

ie doens't like using onclick on a select element. use onchange instead

<script>


function changeVisibility(id,value){
if(value=="single"){
	document.getElementById(id).style.display = 'block';
}else{
	document.getElementById(id).style.display = 'none';
}
}
</script>
<body>
<select onchange="changeVisibility('secondborrowerdiv',this.value)"  class="border" id="life" name="life" title="Please select Single Life or Joint Life" size="1">
<option selected="selected" value="" onClick="showdiv('secondborrowerdiv)">-</option>
<option value="single">Single Life</option>
<option value="joint">Joint Life</option>
</select>

Link to comment
Share on other sites

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.