I'm using a javascript that hides and unhides text based on a button
click. It works great across static fields on a form. The problem I
have is that I'm trying to hide and unhide various fields that are
populated on the page by a database. In other words, sometimes there
are 4 fields, sometimes 6.
I've used various scripts for the hide/unhide function. This is one
I'm using now that I've copied from another source:
<script language = "Javascript">
var isIE=document.all?true:false;
var isDOM=document.getElementById?true:false;
var isNS4=document.layers?true:false;
function toggleT(_w,_h) {
if (isDOM)
{
if (_h=='s')
document.getElementById(_w).style.visibility='visi ble';
if (_h=='h') document.getElementById(_w).style.visibility='hidd en';
}
else if (isIE) {
if (_h=='s')
eval("document.all."+_w+".style.visibility='visibl e';");
if (_h=='h')
eval("document.all."+_w+".style.visibility='hidden ';");
}
else if(isNS4)
{
if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
}
}
</script>
So if in the button field I have onclick =toggleT('divt1','s');
toggleT('divt2','s'); then it will work for spans with id divt1 and
divt2.
If I place the <spantag in front of one of the dynamic fields, then
the same value id=divt shows for each field displayed, so it only works
with the first field with that id. I've tried widening the span beyond
the field so that the span won't be repeated, but it doesn't seem to
work. I'm not sure what the restrictions are regarding how wide a span
can be or what can be enclosed within it.
I'm obviously not a javascript expert, and perhaps the above script is
not the best one to use for my purposes. But I'm sure this issue must
arise a lot and I just don't know how to address it.
Thanks for your help.