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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making a text box and combo visibible

Status
Not open for further replies.

rotsey

Programmer
Nov 23, 2004
135
AU
Hi,

I want to toggle a text box and a combo box from visible to invisible on a web page.

How do i do this?

I have tried display property and it worked the first time i hit a button but did not toggle back when hit the button again.

Is there another way to do this?

rotsey
 
rotsey,

Code:
function toggleT(_w,_h) {
  if (isDOM)
  {
    if (_h=='s') document.getElementById(_w).style.visibility='visible';
    if (_h=='h') document.getElementById(_w).style.visibility='hidden';
  }
  else if (isIE) {
    if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
    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';");
  }
}


Call this function and the parameters are:

_w: which ID (1) or (2)
_h: (h)ide or (s)how


You see ... "if (isIE)" works for internet explorer.



Hope these help
 
function toggleT(txtbx) {
if (document.getElementById(txtbx).style.visibility!="hidden"){
document.getElementById(txtbx).style.visibility="hidden";
} else{
document.getElementById(txtbx).style.visibility="visible";
}
}
 
Thanks guys for your posts.

But I doesn't work properly.

I have a button that i use to toggle and it works the first time I click the button. But it doesn't set them back again.

I am doing this with VS.NET 2003.

Any ideas??

rotsey
 
hi again,

sorry guys I had a bug.

that works fine thanks
 
btw

can you create a variable for the different browsers to refer to in expressions like this

if (isIE)
vBrowser = document.all
if (isNS)
vBrowser = .........
...
...

vbrowser("txt1").value = ""

Something like this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top