Web Hosting Talk







View Full Version : Ajax Show/Hide Content


WireNine
12-07-2008, 09:06 AM
Ajax Show/Hide Content

Looking for a script that will show/hide content.
Upon clicking "Show" the content should be displayed and the text should change to "Hide" which would close the content if clicked.
If Javascript is disabled on the browser, it should automatically display the content.
Does anyone know of such a script? I've seen plenty of them but haven't come across anything that did exactly what I am asking.
1. Show/Hide content text should change
2. Browser compatibility
3. Java support should hide or display the content.
Thanks for looking





__________________█ WireNine.com • Superior Hosting Solutions • 24/7 Support

the_pm
12-07-2008, 10:14 AM
Hey Ali,
We have a script that does exactly what you're asking. We use it all the time on sites. The only element that isn't built into it is the switching from 'show' to 'hide', but that requires all of two lines of additional code.
There's nothing AJAXy about it (nothing's being pulled dynamically from a data source - this would defeat your third requirement ) - it's just a nice, compact piece of JavaScript.
Keep in mind that requirement #3 means the hidden text will display on the screen momentarily while the page loads. It must, because if your default behavior is for the text to simply display, hiding it would be done by the script upon page load, and there would naturally be lag while this took place. This may sound like it's not a problem, but it's usually pretty noticeable when put into action, and this effect may bother you (it may not, but give it some thought).
If you still want the script, let me know and I'll see if I can find a nice, cleaned up version of it for you.





__________________Studio1337 Web Design and Development - formerly Equentity LLCRecent client site launches: TheWHIR.com | 6thgearexperience.com

Energizer Bunny
12-07-2008, 05:07 PM
Mootool is what you should be googling up. You need to modify http://demos.mootools.net/Accordion
And you should be all set.
Jquery is also simple and lots of examples out there.
Cheers





__________________█View My DNS provides Dns Report, Is my Website Down checks and more █ Clients testimonials:" These guys are very responsive and understanding. I love them."-"I have been with this company for over 2years now. Zero down time "-"The ONLY web hosting company that I recommend to use"->█ A1 Web Hosting Solutions█<- Ultimate Proxy Hosting @ ->phpproxyhost.com<-

jasper_
12-07-2008, 06:55 PM
I suggest you use a little bit of jQuery for that.http://www.learningjquery.com/2006/0...-show-and-hide






__________________
J. August
Web

WireNine
12-09-2008, 04:46 AM
jQuery was exactly what I had been searching for, with a bit of customization I was able to achieve 100% of what I wanted
Thanks everyone!





__________________█ WireNine.com • Superior Hosting Solutions • 24/7 Support

jasper_
12-09-2008, 07:08 AM
jQuery rules each and every JavaScript library for its versatility, unobtrusive approach, clean source code, small filesize and speed. Beat that, prototype lib





__________________
J. August
Web