![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 149
Rep Power: 3
![]() |
hidden html?
I want to be able to have a button on my web page, using javaScript, that can hide a <form> element in my html page, but I have no idea how to go about this. I've seen it done on other pages, so I know it's possible, but I'm not sure where to get started.
Could someone point me in the right direction? |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Wow. Search for CSS display and visibility attributes. I recommend reading a tutorial on CSS. Even skimming it, some things are bound to stick and guide you in future.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
If all you are doing is hiding/showing an already existant form,
then you can use CSS as Wei suggests. But if you want your form to be built dynamically, look into using DOM methods like createElement() and appendChild();.
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Feb 2006
Posts: 9
Rep Power: 0
![]() |
This is the simplest I can do:
[html]<html> <body> <input type="button" value="Show/Hide" onclick=" var f = document.getElementById('f'); f.style.display = f.style.display == 'block' ? 'none' : 'block'; " > <form id="f" style="display:block;"> Input: <input type="text"> </form> </body> </html> [/html]
__________________
Programming Tutorial for Absolute Beginners |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|