Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Textbox visibility


Message #1 by "Chris R. Thompson" <cthompson@n...> on Mon, 25 Mar 2002 13:05:28 -0700
I guess I should also mention that it is the "Style" part that is
throwing the error.

Here is my HTML line of code:

<TD VALIGN=3DTOP ALIGN=3DLEFT><FONT
COLOR=3D'<%Response.write(InnerTextFC)%>'><INPUT TYPE=3DRADIO 
id=3DRADIO1
VALUE=3D'U' name=3DApproved<%Response.Write(rsEmpInfo("WRNum").Value & 
"")%>
CHECKED 
onclick=3D'DoOptSwitch("<%Response.Write(rsEmpInfo("WRNum").Value
& "")%>");'>Undecided<INPUT TYPE=3DRADIO id=3DRADIO2 VALUE=3D'Y'
name=3DApproved<%Response.Write(rsEmpInfo("WRNum").Value & "")%>
onclick=3D'DoOptSwitch("<%Response.Write(rsEmpInfo("WRNum").Value &
"")%>");'>Yes<INPUT TYPE=3DRADIO id=3DRADIO3 VALUE=3D'N'
name=3DApproved<%Response.Write(rsEmpInfo("WRNum").Value & "")%>
onclick=3D'DoOptSwitch("<%Response.Write(rsEmpInfo("WRNum").Value &
"")%>");'>No&nbsp;<BR><INPUT TYPE=3DTEXT
NAME=3DDecText<%Response.Write(rsEmpInfo("WRNum").Value & "")%>
ID=3DDecText<%Response.Write(rsEmpInfo("WRNum").Value & 
"")%>></FONT></TD>
And here is my javascript function:

NOTE: The parts that look like this:
"<%Response.Write(rsEmpInfo("WRNum").Value & "")%>" come from a VBScript
recordset that is open and print to the HTML page a number that us
unique since this will produce several radio button/textbox
combinations.  This is why I pass in the number to the function so I
know which set I am hiding/unhiding)


function DoOptSwitch(WRNum)
	{
	var strTemp =3D "DecText" + WRNum
	var obj =3D document.getElementsByName(strTemp);
	if((event.srcElement.value =3D=3D "U") || (event.srcElement.value 
=3D=3D
"Y"))
		{
		window.alert("2")  //Used for testing
		window.alert(obj.name)
		obj.style.visibility =3D"visible";
		}
	else if(event.srcElement.value =3D=3D "N")
		{
		window.alert("3")  //Used for testing
		obj.style.visibility=3D"hidden";
		}
	window.alert("4")  //Used for testing
   }

Thanks,

Chris Thompson


-----Original Message-----
From: Chris R. Thompson
Sent: Tuesday, March 26, 2002 8:54 AM
To: JavaScript HowTo
Subject: [javascript_howto] Re: Textbox visibility

I tried this to sese how it would work.  The "GetElementByID kept giving
me an error, so I used the "GetElementByName" function.  I have both
name and ID in the radio button parameters.  I can fall into the right
part of the if..then statement, but I am getting an error on this line:

obj.style.visibility=3D"hidden";

It tells me it is null or not an object.  Any ideas where I should go
from here?

Thanks,

Chris Thompson



-----Original Message-----
From: Veera Ponna [mailto:kveeram@h...]
Sent: Monday, March 25, 2002 4:13 PM
To: JavaScript HowTo
Subject: [javascript_howto] Re: Textbox visibility

Hi Chris,

 Hope the following example will help you.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D
<SCRIPT LANGUAGE=3Djavascript>
<!--
		function txt_Toggle() {
			var obj =3D document.getElementById("txtName");
		=09
			if(event.srcElement.value =3D=3D "Invisible") {
				obj.style.visibility=3D"hidden";
			}
			else if(event.srcElement.value =3D=3D "Visible") {
				obj.style.visibility=3D"visible";
			}
		}
//-->
</SCRIPT>

</HEAD>
<BODY>
<form name=3D'frm1'>
<input type=3D'radio' name=3D'r1' value=3D'Invisible' 
onClick=3D'txt_Toggle
()'>Invisible<br>
<input type=3D'radio' name=3D'r1' value=3D'Visible' 
onClick=3D'txt_Toggle
()'>Visible<br>
<input id=3DtxtName >
<P>&nbsp;</P>
</form>
</BODY>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D

Wish you all the best

Best Regards
Veera R Ponna


------------------------------------------------------------------------
-
> How do I make a textbox visible or invisible?

I have reference to a text box like this:

document.form1.txtName

and I want it to be switchable visable or invisible.  I have it in an
if..then with a click of a radio button and certain radio buttons I want
it visible, and others I want it hidden.  Thanks in advance.

Thanks,
=3D20
Chris Thompson

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20


---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20

  Return to Index