Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-29-2005, 02:16 PM   PM User | #1
Velcrobelly
New to the CF scene

 
Join Date: Dec 2005
Location: Newcastle upon Tyne
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Velcrobelly is an unknown quantity at this point
Trigger Head action group from popup menu

Hi everyone,
I'm new to the forum and Javascript itself, so apologies for any stupidity.
I am in the planning stages of a website and am researching the best methods to implement certain features.

What I need advice with is whether it is possible to trigger action groups (set to onCall) placed in the Head section of an html page based on user selection from two popup menus. I'm using Adobe GoLive CS by the way.

This particular page will feature 200+ div layers, each of whch need to have their visibility switched using a Show/Hide action depending on the user selection from two popup menus.

The first menu would have three options: City1; City2; City3.
While the second menu would have genre options such as: Art; Film; Exhibition etc. What I would like to achieve is a system where a user selects from either of the popup menus, hits a Submit button and that triggers an appropriate Action Group altering the visibility of select Div layers.

For example, choosing City1 and pressing Submit triggers the City1 action group hiding all designated Divs, while choosing City2 and Art triggers another action group to hide all Divs except those designated.

In short, is it possible to trigger Action Groups (set to onCall) based on the user selection from two popup menus? If it is possible can you clue me in as to where would be a good place to start learning the code/techniques required? I've not had much sucess so far with various Google searches on the subject.

Thanks for your patience and apologies for the long post.
Velcrobelly is offline   Reply With Quote
Old 12-29-2005, 04:08 PM   PM User | #2
konithomimo
New Coder

 
Join Date: Dec 2005
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
konithomimo is an unknown quantity at this point
You could give every div a class and then make the values of your drop down the same as the class names. Then just use a function to show/hide the appropriate divs.
Code:
<html>
<head>
<script type="text/javascript">
function showHide(myclass)
{
var mydivs = document.getElementsByTagName('div');
var i;

for(i=0;i<mydivs.length;i++)
{
if(mydivs[i].className==myclass)
{
mydivs[i].style.display='block';
}
else
{
mydivs[i].style.display='none';
}
}
}
</script>
</head>
<body>
<form>
<select onchange="showHide(this.options[this.selectedIndex].value)">
<option value="first">First group
<option value="second">Second group
<option value="third">Third group
</select>
</form>
<div class="first" style="display:none">
This is part of the first group.
</div>
<div class="second" style="display:none">
This is part of the second group.
</div>
<div class="third" style="display:none">
This is part of the third group.
</div>
<div class="first" style="display:none">
This is also part of the first group.
</div>
</body>
</html>
konithomimo is offline   Reply With Quote
Old 12-29-2005, 04:52 PM   PM User | #3
Velcrobelly
New to the CF scene

 
Join Date: Dec 2005
Location: Newcastle upon Tyne
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Velcrobelly is an unknown quantity at this point
Thanks konithomimo,

Can you recommend any sites where I could figure out what that all means? Like I mentioned in my first post, i'm new to Javascript...well writing my own anyway.
Velcrobelly is offline   Reply With Quote
Old 12-29-2005, 05:01 PM   PM User | #4
Nischumacher
Regular Coder

 
Nischumacher's Avatar
 
Join Date: Oct 2005
Location: Bombay, India
Posts: 196
Thanks: 0
Thanked 2 Times in 2 Posts
Nischumacher has a little shameless behaviour in the past
take a look at W3 Schools.
__________________
- NS 666
.net DEVILoper
Nischumacher is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:44 PM.


Advertisement
Log in to turn off these ads.