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

How to hide an input text? 1

Status
Not open for further replies.

thelordoftherings

Programmer
Joined
May 16, 2004
Messages
616
Location
IL
Hello,

I would like to create an input text and a button.
At first click the input will be hidden, at second click the input will be showen again and so on...
How do I do that?
 
This does exactly what you've asked for. A search would have thrown up many similar bits of code.

Code:
<html>
<head>
	<script type="text/javascript">
	<!--
		function toggleElement(elementName, displayType) {
			if (document.forms[0].elements[elementName].style.display == 'none') {
				document.forms[0].elements[elementName].style.display = displayType;
			} else {
				document.forms[0].elements[elementName].style.display = 'none';
			}
		}
	//-->
	</script>
</head>
<body>
	<form>
		<input type="button" onclick="toggleElement('myText', '');" value="Toggle input box visibility" />
		<input type="text" name="myText" />
	</form>
</body>
</html>

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top