tripwater
10-20-2003, 04:22 PM
I have a form that when you select a country other than USA or you select the Default which has a value of "", you will see a drop list of states. If you change the country to another country then I hide the select and show a text field allowing them to type the name of their providence.
I have it working in IE and can't get it to work in Netscape/Mozilla/Galleon. Right now in these other browsers, if you change the country to say Canada, it hides the select and shows the text field but when you pick USA again it does not go back. I was wondering if someone could take a look at my code and tell me what I am doing wrong.
Here is my HTML:
<html>
<head>
<title>hide Drop Down</title>
<style>
<!--
#select1 {position:absolute; left: 0px; top: 80px; width:200px; height: 50px; visibility:visible; z-index: 100;}
#select2 {position:absolute; left: 200px; top: 80px; width:200px; height: 200px; visibility:hidden; z-index: 100;}
#select3 {position:absolute; left: 200px; top: 80px; width:200px; height: 200px; visibility:visible; z-index: 100;}
//-->
</style>
<script language="JavaScript1.2" src="hidefield.js">
</script>
</head>
<form name="form1"> <br>
<div id="select1">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<select name=dF onchange="javascript:change();">
<option value="">Select Country
<option value=0> USA
<option value=1> Canada
<option value=2> UK
</select>
</td>
</tr>
</table>
</div>
<div id="select2">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<input type=text name=state>
</td>
</tr>
</table>
</div>
<div id="select3">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<select name=dF2>
<option>Hello
<option>World
</select>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Here is my src JS code :
ns5 = (document.getElementById&&!document.all)? true:false
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
NS6 = (document.getElementById && !document.all)
IE = (document.all)
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4")
var layerRef,styleRef
if (NS6)
{
layerRef = "document.getElementById('"
styleRef = "').style."
}
else
{
layerRef = (document.all) ? "" : "document.";
styleRef = (document.all) ? ".style." : ".";
}
function show(block)
{
eval(layerRef + block + styleRef + "visibility = 'visible'");
}
function hide(block)
{
eval(layerRef + block + styleRef + "visibility = 'hidden'");
}
function change()
{
if (document.form1.dF.value == 0)
{
hide('select2');
show('select3');
}
else
if (document.form1.dF.value != 0 && document.form1.dF.value != "")
{
hide('select3');
show('select2');
}
}
Thanks ahead for any help on this.
I have it working in IE and can't get it to work in Netscape/Mozilla/Galleon. Right now in these other browsers, if you change the country to say Canada, it hides the select and shows the text field but when you pick USA again it does not go back. I was wondering if someone could take a look at my code and tell me what I am doing wrong.
Here is my HTML:
<html>
<head>
<title>hide Drop Down</title>
<style>
<!--
#select1 {position:absolute; left: 0px; top: 80px; width:200px; height: 50px; visibility:visible; z-index: 100;}
#select2 {position:absolute; left: 200px; top: 80px; width:200px; height: 200px; visibility:hidden; z-index: 100;}
#select3 {position:absolute; left: 200px; top: 80px; width:200px; height: 200px; visibility:visible; z-index: 100;}
//-->
</style>
<script language="JavaScript1.2" src="hidefield.js">
</script>
</head>
<form name="form1"> <br>
<div id="select1">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<select name=dF onchange="javascript:change();">
<option value="">Select Country
<option value=0> USA
<option value=1> Canada
<option value=2> UK
</select>
</td>
</tr>
</table>
</div>
<div id="select2">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<input type=text name=state>
</td>
</tr>
</table>
</div>
<div id="select3">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<select name=dF2>
<option>Hello
<option>World
</select>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Here is my src JS code :
ns5 = (document.getElementById&&!document.all)? true:false
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
NS6 = (document.getElementById && !document.all)
IE = (document.all)
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4")
var layerRef,styleRef
if (NS6)
{
layerRef = "document.getElementById('"
styleRef = "').style."
}
else
{
layerRef = (document.all) ? "" : "document.";
styleRef = (document.all) ? ".style." : ".";
}
function show(block)
{
eval(layerRef + block + styleRef + "visibility = 'visible'");
}
function hide(block)
{
eval(layerRef + block + styleRef + "visibility = 'hidden'");
}
function change()
{
if (document.form1.dF.value == 0)
{
hide('select2');
show('select3');
}
else
if (document.form1.dF.value != 0 && document.form1.dF.value != "")
{
hide('select3');
show('select2');
}
}
Thanks ahead for any help on this.