Skip to main content

Problem:

You might want to hide or make invisible a control (e.g. input field) in a HTML form based on some values or events.

Resolution:

The best way to do this is to use JavaScript, a programming language that is common on Web pages. You can have JavaScript to determine when to hide a field. Although you can do many things with JavaScript, it would require you to know about HTML codes as well.

The following JavaScript makes input2 invisible when the onclick_func function is executed and the value of input1 is "fano":

function onclick_func()

{

if (document.form1.input1.value == "fano")

document.form1.input2.style.display = 'none'

}

There are so many references of JavaScript on the Internet, and you will be able to find ways to enhance interaction with your web pages.

Old KB# 4053