User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,006 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,848 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2314 | Replies: 3
Reply
Join Date: Oct 2007
Posts: 63
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is offline Offline
Junior Poster in Training

Hide/Show html forms using javascript

  #1  
Apr 28th, 2008
Hi guys,

I am working on a webpage which holds 2 different html forms. One of them is a radio button form and the other one is a drop down menu. I also have two links on the page. I want to make it so that when someone clicks on link 1 the radio button form will be visible, and if they click on link 2, the radio button form will be hidden and the drop down menu will be visible. It is probably very easy but I am new to this stuff and I could use your help. Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 3
Reputation: yesintlcorp is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
yesintlcorp yesintlcorp is offline Offline
Newbie Poster

Re: Hide/Show html forms using javascript

  #2  
Apr 29th, 2008
Try this one out you might like it:

Here is a small piece of code which will give you your browser details such as...
current resolution
maximum resolution
browser name
browser version:
color depth
code name
platform
java status


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Browser Details...</title>
  6. <script language="javascript" type="text/javascript">
  7. function details() {
  8. window.onerror=null;
  9. document.frmDetails.navigator.value = navigator.appName;
  10. document.frmDetails.version.value = navigator.appVersion;
  11. document.frmDetails.colordepth.value = window.screen.colorDepth;
  12. document.frmDetails.width.value = window.screen.width;
  13. document.frmDetails.height.value = window.screen.height;
  14. document.frmDetails.maxwidth.value = window.screen.availWidth;
  15. document.frmDetails.maxheight.value = window.screen.availHeight;
  16. document.frmDetails.codename.value = navigator.appCodeName;
  17. document.frmDetails.platform.value = navigator.platform;
  18. if (navigator.javaEnabled() < 1) document.frmDetails.java.value="No";
  19. if (navigator.javaEnabled() == 1) document.frmDetails.java.value="Yes";
  20.  
  21. }
  22.  
  23. </script>
  24. </head>
  25.  
  26. <body onload="details();">
  27.  
  28.  
  29. <form name=frmDetails>
  30. <table border=1 width=499>
  31.  
  32. <tr>
  33. <td width="133">current resolution:</td>
  34. <td width="350" align=center><input type=text size=4 maxlength=4 name=width>
  35. x <input type=text size=4 maxlength=4 name=height></td>
  36. </tr>
  37.  
  38. <tr>
  39. <td>
  40. browser:</td>
  41. <td align=center><input type=text name=navigator></td>
  42. </tr>
  43. <tr>
  44. <td>
  45. max resolution:</td>
  46. <td align=center><input type=text size=4 maxlength=4 name=maxwidth>
  47. x <input type=text size=4 maxlength=4 name=maxheight></td>
  48. </tr>
  49.  
  50. <tr>
  51. <td>
  52. version:</td>
  53. <td align=center><input type=text name=version></td>
  54. </tr>
  55.  
  56. <tr>
  57. <td>
  58. color depth:</td>
  59. <td align=center><input type=text size=2 maxlength=2 name=colordepth> bit</td>
  60. </tr>
  61.  
  62. <tr>
  63. <td>
  64. code name:</td>
  65. <td align=center><input type=text name=codename></td>
  66. </tr>
  67.  
  68. <tr>
  69. <td>
  70. platform:</td>
  71. <td align=center><input type=text name=platform></td>
  72. </tr>
  73.  
  74. <tr>
  75. <td>
  76. java enabled:</td>
  77. <td align=center><input type=text size=3 maxlength=3 name=java></td>
  78. </tr>
  79.  
  80. <tr>
  81. <td colspan=2 align=center>
  82. <input type=button name=again value="Refresh?" onclick="details();"></td>
  83. </tr>
  84. </table>
  85. </form>
  86.  
  87. </body>
  88. </html>


This comes from http://www.weberdev.com/get_example-4758.html

Thanks,

Yesintlcorp
<snipped>
Last edited by peter_budo : Apr 30th, 2008 at 7:45 am. Reason: Keep It Organized - plase use [code] tags
Reply With Quote  
Join Date: Apr 2008
Posts: 3
Reputation: yesintlcorp is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
yesintlcorp yesintlcorp is offline Offline
Newbie Poster

Re: Hide/Show html forms using javascript

  #3  
Apr 29th, 2008
Have a look at this one as well: it might be more relevant to your question:

Look into CSS particularly the visibility: hidden/visible attribute. I have an example on my hard drive which I post here as I haven't answered this question here before... much!!:


Help with Code Tags asp Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
  2. <head>
  3. <title>ShowHideControl</title>
  4. <script type="text/javascript">
  5. function toggleVisibility(controlId)
  6. {
  7. var control = document.getElementById(controlId);
  8. if(control.style.visibility == "visible" || control.style.visibility == "")
  9. control.style.visibility = "hidden";
  10. else
  11. control.style.visibility = "visible";
  12. }
  13. </script>
  14. <script type="text/javascript">
  15. function toggleTable(button)
  16. {
  17. if(button.value == "Show")
  18. {
  19. button.value = "Hide";
  20. document.getElementById("table1").style.visibility = "visible";
  21. }
  22. else
  23. {
  24. button.value = "Show";
  25. document.getElementById("table1").style.visibility = "hidden";
  26. }
  27. }
  28. </script>
  29. </head>
  30. <body>
  31. <input type="text" id="TextBox1" />
  32. <input type="button" id="btnShowHide" value="Show/Hide" onclick="toggleVisibility('TextBox1');" />
  33. <table id="table1" style="visibility: hidden">
  34. <tr><td>A table Cell</td></tr>
  35. </table>
  36. <input type="button" id="btnToggle" value="Show" onclick="toggleTable(this);" />
  37. </body>
  38. </html>

This comes from
http://www.daniweb.com/forums/thread88102.html

Thanks,

Yesintlcorp
<snipped>
Last edited by peter_budo : Apr 30th, 2008 at 7:50 am.
Reply With Quote  
Join Date: Apr 2008
Posts: 3
Reputation: yesintlcorp is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
yesintlcorp yesintlcorp is offline Offline
Newbie Poster

Re: Hide/Show html forms using javascript

  #4  
Apr 30th, 2008
Hello still_learning,
I have tried and tested this works:

docuemnt.getElementbyId("<tableid>").style.visibility:"visible" or "hidden" works fine as per your need.

Regards,

yesintlcorp
<snipped>
Last edited by peter_budo : Apr 30th, 2008 at 7:50 am. Reason: Keep It Spam-Free Do not spam, advertise, plug your website, or engage in any other type of self promotion.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 10:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC