Writing Friendly Code 9. Tool Kit | WebReference

Writing Friendly Code 9. Tool Kit

home / web / dev / friendly

Writing Friendly Code

9. Handy Tool Kit - setVis and btnVis

setVis(what,boo) writes to the visibility property. what is the name of the page or control and boo is the Boolean string of "visible" or "hidden." It is converted for NS, which prefers "show" and "hide" when it writes and reads to what it calls a layer.


function setVis(what,boo){
if(brid=="IE")document.all[what].style.visibility=boo;
   if(brid=="NS"){
     if(boo=="hidden")boo="hide";
     if(boo=="visible")boo="show";
     document[what].visibility=boo;
   } 
} 

btnVis() sets the page tab button state and changes the text on the buttons if necessary. The parameter is a number indicating the page, which helps resolve the buttons that are not numbered. IE uses the html approved "disabled" property to "gray out" a form element and prevent the user from clicking it. This is an extremely convenient way to indicate where you are. Setting the disabled property to the empty string returns it to the default, which is "not disabled." 

Navigator doesn't support disabled, unfortunately. That makes it a bit more cumbersome to work with the buttons. I write the value "Here" on the button that marks our location. But then I have to write the correct name on every other button, including the Forum and Resource buttons, which have the same behavior as the page number buttons. 

Also, note the path to the buttons. IE uses the handy document.all shortcut, and NS has to go from the document to the container that holds the form,and use it's document object to retrieve the form and the button. Since the buttons are on two different forms on two different layers, we need two references, formB for the page numbers and formB1 for the Code and Forum buttons. Since I don't use the "var" keyword to declare them, they become global and I can use them later. Which is good, because I only want to type them once.


function btnVis(bwot){ 
var offB=("btn" +bwot); 
if(bwot==n1)offB="codebtn";
if(bwot==n2)offB="forumbtn";
if(brid=="IE")document.all[offB].disabled=""; 
   if(brid=="NS"){
     formB1=document.toolBox.document.forms[0]; 
     formB=document.tabBar.document.forms[0]; 
     if(bwot!=0 && bwot<=n3)formB[offB].value= 'Pg '+bwot; 
     if(bwot==0)formB[offB].value="Cover";
     if(bwot==n1)formB1[offB].value="Code";
     if(bwot==n2)formB1[offB].value="Forum";
   } 
}

Doing that Thing You Do 

Comments are welcome

 


Created: Dec. 2, 1999
Revised: Dec. 7, 1999

URL: https://webreference.com/dev/friendly/