I just published a new article on the Tips and Tricks page but this one has a difference. You may have noticed a few of my pages have optional C# and VB code sections that can be chosen on-the-fly as you read. These are simple DHTML scripts that turn different sections of the page on or off according to choice. The problem was with the method, which I got from another web-site I hasten to add, was that if more than one section of code needs swapping out then the javascript becomes ever more complex with each new bit. What I needed was a way of turning on all the C# or all the VB in one go.
This is the first time I've messed about with DHTML in any serious way and so I'm rather pleased with the end result. What I did was give all the C# or VB statements a unique ID based on the pattern "CSA" "CSB" or "VBA" "VBB" and so-on. Then I created code that went through all the specially named elements one by one turning them on or off as needed. Finally I put a couple of sexy mouseover buttons on the page to finish the thing up and voila...
If you'd like to see the code in it's production form go read the article. If you'd like to see the bare-bones dynamic page you can see it here.
No comments:
Post a Comment