Modifying CSS using Javascript

She has: 88 posts

Joined: Sep 2001

I have a page with 13 radio buttons in one group (meaning they're mutually exclusive). I am trying to change the visibility of a nearly equal number of "layers" based on the checked radio button.

Example: one of the radio buttons is for Decking. If the user checks the Decking button, a layer is made visible on the right side of the form with all the specification fields required for Decking.

That part works, but part of my error trapping involves hiding a visible layer should the user change their mind and select another radio option. For example, initially selecting Decking, then decide they want Engineered Flooring instead (Engineered Flooring has all different specification fields.)

Here's the page if my explanation isn't clear. Currently Decking and Engineered Flooring are the only two radio buttons that I've coded. Any insights, tutorials, solutions, guesses, comments are appreciated.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I suppose you'd have to have a bit of Javascript to recurse through all the relevant layers, turning them invisible, before making the appropriate selected layer visible. Or something along those lines.

Before getting into that, I think there are some pre-made scripts that work like this already. Check out dynamicdrive.com first. Smiling

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

It may look a little different to what you need, but it's essentially the same. You'll have to adapt the HTML part to suit your form, but the Javascript itself should be fine. Smiling

Oh, and it only confirms support for IE, but it works on Firefox, so I suppose it'll work on Netscape and the KHTML clients too. Probably a good idea to test first. Wink

She has: 88 posts

Joined: Sep 2001

I think I've looked at every script over at Dynamic Drive (I love that place!) and didn't see anything that looked like it might hide my layers. Thanks!

She has: 88 posts

Joined: Sep 2001

Oh, thanks! I didn't think about adapting that script. I already use that one.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.