Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 20th, 2006, 8:00 PM   #1
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
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?
Writlaus is offline   Reply With Quote
Old Mar 20th, 2006, 8:42 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Mar 30th, 2006, 10:36 AM   #3
Agent 47
Hobbyist Programmer
 
Agent 47's Avatar
 
Join Date: Nov 2005
Posts: 122
Rep Power: 3 Agent 47 is on a distinguished road
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"
Agent 47 is offline   Reply With Quote
Old Mar 30th, 2006, 11:08 AM   #4
Kakao
Newbie
 
Join Date: Feb 2006
Posts: 9
Rep Power: 0 Kakao is on a distinguished road
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]
Kakao is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC