By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

how to hide a text box when a button is clicked

P: 2
i have a text box and a button in a form. when i click on the button is it possible to hide the textbox? the textbox should not appear on the screen after the button is clicked
Feb 2 '07 #1
Share this Question
Share on Google+
3 Replies

ronverdonk
Expert 2.5K+
P: 4,258
I am not sure, but when it is possible, I am sure it should be done using JavaScript and the DOM. So I will move this thread to the JavaScript forum.

Ronald :cool:
Feb 2 '07 #2

Nert
P: 64
i have a text box and a button in a form. when i click on the button is it possible to hide the textbox? the textbox should not appear on the screen after the button is clicked
hi..,

Yes it's possible to hide the textbox using javascript.., let me give you and example on how to do that.

let say we have this textbox named "txt" and an id of "txt".
Expand|Select|Wrap|Line Numbers
  1.       <form name="form1" id="form1" action="url" method="post">
  2.            <input type="text" name="txt" id="txt" value="Some Text" />
  3.            <input type="button" name="button" value="Click to hide the textbox" 
  4.            onclick="document.getElementById('txt').style.visibility='hidden';"/>
  5.            <input type="button" name="button" value="Click to show the textbox" 
  6.            onclick="document.getElementById('txt').style.visibility='visible';"/>
  7.      </form>
  8.  
i hoped that simple example will help you.

--nert (^_^)
Feb 3 '07 #3

dmjpro
100+
P: 2,476
u can also do it using ..............
document.getElementById('id_name').style.display = 'block' for visibility and = 'none' for invisibility...
thankkkksssssss--------------------------
Feb 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.