iGuest 3 Report post Posted November 7, 2004 This is my very first script, before I knew what was out there. It works in IE 5 and up. Not sure about netscape or mozilla. (I recently d/led mozilla and it's great for javascripts. Much less typing.) <script language="javascript"><!--function toggle(what){ if(document.all[what].style.display == "none"){ document.all[what].style.display = "block"; }else{ document.all[what].style.display = "none"; }}//--></script><a href="javascript:toggle('myDiv')">Toggle</a><br><div style="display:none;" id="myDiv"> Some Text... Blah Blah Blah....</div>This is what I can remember. Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 9, 2004 light & cool!!!thanks... Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 9, 2004 Short and sweet. Nice simple code. I'll be using it. Thanks man. Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 10, 2004 Wow this is great for little help links and such, nice! Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 23, 2004 Short and clean... thanks Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 12, 2005 That is pretty cool... might use it thanks Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 12, 2005 document.all is a IE only DOM. Use this for the cross-browser version. I just changed the way to get the element. <script language="javascript"><!--function toggle(what){ if(document.geElementById(what).style.display == "none"){ document.getElementById(what).style.display = "block"; }else{ document.getElementById(what).style.display = "none"; }}//--></script> Use the same link/div. Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 8, 2008 There is a shorter script to do that: Function toggleId(id) { element = document.GetElementById(id); modus = (element.Style.Display == 'none' || element.Style.Display == '') ? 'block' : 'none'; element.Style.Display = modus;} Share this post Link to post Share on other sites
iGuest 3 Report post Posted May 16, 2008 Help with code Toggle display in page script Replying to unimatrix0 Hi, I have used your code but found that I am unable to use it more than once on my web page. I have a few headings for which I want the text below it to appear and disappear.. I just copied and pasted the code a few times and changed the words but found it wasnt working. How can I use the code given so that I can have a few headings on the page which will have different text appear and disappear? Thanks for help. Share this post Link to post Share on other sites