?
Solved

JAVASCRIPT TEXTBOX VISIBILITY

Posted on 2008-11-04
6
Medium Priority
?
776 Views
Last Modified: 2011-09-20
Hi,
I am writing a function in javascript to make eithr show or hidden the Textboxes on the form How can I do it???

iTS URGENT\\\

Thanks
0
Comment
Question by:bhavin8282
  • 4
6 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22878959
most likely what you are after is the toggle functionality below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title></title>
<script type="text/javascript">
function show(eid){document.getElementById(eid).style.display='';}
function hide(eid){document.getElementById(eid).style.display='none';}
function getDisplay(eid){return document.getElementById(eid).style.display;}
function toggle(eid){
	if( getDisplay(eid)==='none')
	{
		show(eid);
	}
	else
	{
		hide(eid);
	}
}
</script>
</head>
<body>
<span onclick="show('usernameField')">Show</span> | <span onclick="hide('usernameField')">Hide</span> | <span onclick="toggle('usernameField')">Toggle</span>
<form>
	<div id="usernameField">Username: <input type="text" name="username"/></div>
	<div id="addressField">Address: <input type="text" name="address"/></div>
</form>
</body>
</html>

Open in new window

0
 
LVL 18

Expert Comment

by:ChetOS82
ID: 22878968
document.getElementById('textbox1').style.display='none'; // Hide
document.getElementById('textbox1').style.display='';  // Show

Make sure you specify an id on the input box.

<input type="text" id="textbox1" name="textbox1" value="" />
0
 

Author Comment

by:bhavin8282
ID: 22879453
can u send me using style.vissibility
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 82

Accepted Solution

by:
hielo earned 1500 total points
ID: 22879495

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title></title>
<script type="text/javascript">
function show(eid){document.getElementById(eid).style.visibility='';}
function hide(eid){document.getElementById(eid).style.visibility='hidden';}
function getDisplay(eid){return document.getElementById(eid).style.visibility;}
function toggle(eid){
	if( getDisplay(eid)==='hidden')
	{
		show(eid);
	}
	else
	{
		hide(eid);
	}
}
</script>
</head>
<body>
<span onclick="show('usernameField')">Show</span> | <span onclick="hide('usernameField')">Hide</span> | <span onclick="toggle('usernameField')">Toggle</span>
<form>
	<div id="usernameField">Username: <input type="text" name="username"/></div>
	<div id="addressField">Address: <input type="text" name="address"/></div>
</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22880006
glad to help
0
 
LVL 82

Expert Comment

by:hielo
ID: 22880021
Why the grade? You got what you asked for.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question