JAVASCRIPT TEXTBOX VISIBILITY

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
bhavin8282Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
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
ChetOS82Commented:
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
bhavin8282Author Commented:
can u send me using style.vissibility
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

hieloCommented:

<!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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
glad to help
0
hieloCommented:
Why the grade? You got what you asked for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.