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?
 
hieloConnect With a Mentor Commented:

<!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
 
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
bhavin8282Author Commented:
can u send me using style.vissibility
0
 
hieloCommented:
glad to help
0
 
hieloCommented:
Why the grade? You got what you asked for.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.