|
Author
|
Topic: Javascript help
|
Titanium Warrior
Alpha Geek
Member # 1885
Member Rated:
|
posted September 28, 2006 22:49
Hi guys... looking for a little help... trying to make an expanding/collapsing text box, and I have a link that can expand and collapse it, but I also wanted to add another collapse link the actual expanded box.
The example can be found here http://www.columbiafuels.com/bio_heat_myths.htm
There isn't anything actually wrong with it, it's just that I've added a second link to collapse the box, but I wanted to make both links switch from 'close' back to 'expand'
-TiW
-------------------- I used to have super powers until my therapist took them away.
Posts: 333 | From: Victoria, BC Canada | Registered: Dec 2002
| IP: Logged
|
|
Jace Raven
 Solid Nitrozanium SuperFan!
Member # 2444
Member Rated:
|
posted September 29, 2006 00:57
scrap the javascript in this case. Use CSS.
Posts: 1791 | From: Seoul, Korea | Registered: Nov 2003
| IP: Logged
|
|
dragonman97
 SuperFan!
Member # 780
Member Rated:
|
posted September 29, 2006 08:22
quote: Originally posted by Jace Raven: scrap the javascript in this case. Use CSS.
Wrong answer. CSS cannot readily do what he's asking for. I might say that it's a kind of ugly thing to do, but if that's the client request, so be it.
Unfortunately, I can't really look at it in depth right now - basically, you need to have a single function that is passed parameters, which changes the text of *both* links upon clicking it. Currently, it's very broken, as if you toggle via different buttons, it sort of works, but looks funky.
Think along the lines of: function toggle_section(section_name)
Then, have appropriately IDed sections and links, such that a simple function can get the elements and alter them accordingly.
The *most* important part is that you put everything in tidy DIVs with links that work. Ideally, I'd suggest that it degrades gracefully to showing everything, and maybe have the links go to a 'more info' page. This way someone with Javascript disabled...or a screen reader, stands a better chance of getting at your information.
Get this extension, and learn to use it to the fullest: http://chrispederick.com/work/webdeveloper/
-------------------- There are three things you can be sure of in life: Death, taxes, and reading about fake illnesses online...
Posts: 9053 | From: Westchester County, New York | Registered: May 2001
| IP: Logged
|
|
Titanium Warrior
Alpha Geek
Member # 1885
Member Rated:
|
posted September 29, 2006 08:39
Thanks... I took a different approach and I like the results better now. Thanks D-man, you gave me some thought starters and then I took a different approach that works great.
Cheers -TiW
-------------------- I used to have super powers until my therapist took them away.
Posts: 333 | From: Victoria, BC Canada | Registered: Dec 2002
| IP: Logged
|
|
|