Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help Hide and show script 1

Status
Not open for further replies.

venomdesign

Programmer
Apr 6, 2001
18
0
0
US
I have this wirtten but it doesn't work in netscape is there anyone that could help me with this. It is supposed to hide the select box when the one value is 7 but not hide whenever a value is other than 7. Works in IE but not netscape even though I scripted for both layers and IE.

<head>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
if (document.layers)
var doc = 'document.', vis = '.visibility';
if (document.all)
var doc = 'document.all.', vis = '.style.visibility';
function show(object) {
if (document.layers || document.all)
eval(doc + object + vis + ' = &quot;visible&quot;');
}
function hide(object) {
if (document.layers || document.all)
eval(doc + object + vis + ' = &quot;hidden&quot;');
}
function hideAll() {
hide('roleSelect');
}
function showAll() {
show('roleSelect');
}
function checkhide() {
if (document.forms[0].dealid.value == 7) {
hideAll();
} else if (document.forms[0].dealid.value != 7) {
showAll();
}
}
//-->
</SCRIPT>
<STYLE type=&quot;text/css&quot;>
#roleSelect { position: absolute; }
</STYLE>
</head>

<body>

<form>
<select name=&quot;dealid&quot; onchange=&quot;checkhide()&quot;>
<option value=&quot;23&quot;>23
<option value=&quot;7&quot;>7
<option value=&quot;63&quot;>63
</select>
</form>

<span id=&quot;roleSelect&quot;>
<form>
<select name=&quot;formId&quot; multiple size=&quot;9&quot; width=&quot;300&quot; style=&quot;width:300px&quot;>
<option>dlgh
</select>
</form>
</span>
 
because netscape syntax about show and hide is :
visible=hide (not visibility=hidden)

the real cross browser property for this is display=none, but it doesn't behave exactly the same (it reserves the place to display the element even if it's not to be displayed)

more on this in the javascript forum (i KNOW that your problem is more a css one, but the cross browser issues on this are developped in the jscript forum) - use the search tab and &quot;hide show netscape&quot; for example as keywords. I bet you'll get many many threads, detailling solutions for your problem ! let me know if it goes ...
 
Thanks for the help IZA it made me think and I rewrote a part to further define the two broswers. This works if anybody needs to use a select box to hide and show, cross browser capable.

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

if (ns4)
var doc = 'document.layers.', vis = '.visibility';
if (ie4)
var doc = 'document.all.', vis = '.style.visibility';
var object = 'roleSelect';

function show(object) {
if (ie4)
eval(doc + object + vis + ' = &quot;visible&quot;');
else
if (ns4)
eval (doc + object + vis + ' = &quot;show&quot;');
}
function hide(object) {
if (ie4)
eval(doc + object + vis + ' = &quot;hidden&quot;');
else
if (ns4)
eval(doc + object + vis + ' = &quot;hide&quot;');
}
function hideAll() {
hide('roleSelect');
//hide('text2');
}
function showAll() {
show('roleSelect');
//show('text2');
}
function checkhide(object) {
if (document.forms[0].dealid.selectedIndex != 1) {
//alert (document.forms[0].dealid.selectedIndex);
showAll();
} else {
hideAll();
}
}
//-->
</SCRIPT>
<STYLE type=&quot;text/css&quot;>
#roleSelect { position: absolute; }
</STYLE>
</head>

 
thank you for letting everyone know the correct syntax :)
happy it hellped :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top