how to hide a text box when a button is clicked

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
chitrapu
Forum Newbie
Posts: 23
Joined: Sun Jan 14, 2007 11:39 pm

how to hide a text box when a button is clicked

Post by chitrapu »

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
wildwobby
Forum Commoner
Posts: 66
Joined: Sat Jul 01, 2006 8:35 pm

Re: how to hide a text box when a button is clicked

Post by wildwobby »

chitrapu wrote: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
use javascript.

put the textbox in a div and do somthing like:

Code: Select all

function hideTextbox(div) {
var textbox = document.getElementById['div'];

textbox.style.visibility = 'hidden'; //hides text box
}
on the button add a action or what ever its called so it is like onSubmit = hideTextbox(textfield);


Im no Javascript pro, but i think thats how its done.
Last edited by wildwobby on Thu Feb 01, 2007 10:00 pm, edited 1 time in total.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

document.getElementById('whatever').style.display = "none";
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You don't sound like you're aware so, just so you know, backwards compatibility (for people who don't have IE7 yet, or people who refuse to upgrade browsers) use document.all['whatever'].style and document.layers['whatever']
chitrapu
Forum Newbie
Posts: 23
Joined: Sun Jan 14, 2007 11:39 pm

Re: how to hide a text box when a button is clicked

Post by chitrapu »

thank a lot its working , but i have the same problem with a buttonalso . that code does is not working for a button.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

What...? You mean displaying/hiding buttons? I'm not sure I understood what you asked.
Post Reply