Change the visibility of an HTML textbox.

I am able to hide a textbox by doing:
var tb1 = document.getElementById(id);
tb1.style.display = "none";

However, I am not able to make it visible by doing this:
tb1.style.display = "";

Please let me know what I could be missing. Thanks!
dshrenikAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
if your textbox is set with : Visible="false"

<asp:Textbox runat="server" id="Texbox1" Visible="false" Text="blabla" />

the textbox DON'T EXIST in the page so you can ask javascript to show it

use :

<asp:Textbox runat="server" id="Texbox1" style="display:none"  Text="blabla" />
0
 
leakim971PluritechnicianCommented:
use : tb1.style.display = "block";
0
 
dshrenikAuthor Commented:
Still does not work. :(
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
leakim971Connect With a Mentor PluritechnicianCommented:
another possible problem :

<div style="display:none">
<asp:Textbox runat="server" id="Texbox1" Text="blabla" />
</div>

you CAN'T SHOW it here too because the div around it is hidden
0
 
leakim971PluritechnicianCommented:
<< the textbox DON'T EXIST in the page so you CAN'T ask javascript to show it >>
0
 
dshrenikAuthor Commented:
I am actually creating an HTML textbox through JavaScript.
0
 
dshrenikAuthor Commented:
I think the textbox is inside  a <td>, and I have set:
<td style="display: none">

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