![]() |
Simple multi CSS div display from drop down box!
Hi guys,
Sorry my Javascript knowledge is seriously more rusty than I had original hoped for :( I'm trying to use a conditional drop-down box to display certain CSS Div's based on certain selections. I found some code on here but i'm having issues getting it to work Can't remember what to do regarding 'if' and 'if else' to get this functioning properly. Code:
<script language="javascript"> |
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
Thanks VW, Great piece of Maths there! ....but I don't think i explained myself properly...
The idea is that I need to add new conditions to the script, I need about 50 conditions in all based on any random combination, hence having to declare the condition for each drop-down option. For example, option 6 might be: 1-block, 2 - none, 3 - block/ option 7: 1-block, 2 -none, 3 -none option 8: 1-block, 2-block, 3-block Any ideas? |
Little late to the dance, but using VW's idea, try this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
Thank you so much jmrker... but....I'm so Sorry! You lot are crazy geniuses !!!!!!!!!!!!!!!!
I don't think I'm articulating this problem very well.... simply I need control over what each selection creates. So I know that selection (1) needs to show DIV 1,2,3, (2) needs to show 2 & 3... (49) Needs to show Div 3,4.. and so on. Hence the original question based on conditions! Please seek clarification if you need it before making me feel extremely guilty!!! :) Thank you so much for your efforts so far, you don't know much they're appreciated! :thumbsup: |
Still confused after all this time ...
More questions then:
1. How many <div> sections do you want to display. Script allows for 1-8, currently 5. 2. Specify which <div> is displayed via a binary number converted to decimal. ie, Code:
<option value="7">selection 1</option> <!-- 7 = 00111 -->3. Do you want an array assignment rather than the random generation? ie, Code:
DivValues = ['','7','6',..............'12']; // set-up values for select optionsAlternatively, you can use the longer hard-coded way commented out via the <!-- xxx --> as shown in question #2. |
Big thanks again....
Basically what I am trying to achieve is displaying what is available in each city when user selects their city in the drop-down-box. There are 4 div's... So say for city 1, the images/info available to them is shown in Div 1 & Div 2 city 2 has Div 1, 2 & 4 city 3 has Div 2 & 4 city 4 has Div 3 & 4 city 5 has Div 1, 2, 3 & 4 and so on for 50 or cities I don't need it to be random, I just need to declare what each selection shows, as it may change in the future. I think thats what you're trying to ask in question 3. Can't thank you enough for all the trouble I'm putting you through :thumbsup: Sorry for being a pain in the back side ;) |
Post a link to your images and list what combinations you need for each city.
How are the images related to the <DIV> tags? I'm not a very good mind reader. :) |
What's the matter with your mind reading abilities then? :D
I'm using a mix of text and image for each bit of info, so hence why I'm going down the <div> route! For example: <div id="form2a" style="display:none"> <img src"image1> info here </div> City 1 needs to Show: Div1, Div 2, Div 3, City 2 needs to show: Div1, Div 2, Div 4. Just show me how to change to condition for each selection. I feel like i've wasted enough of your time already! :) You're a legend! |
Quote:
I need to know the conditions you wish to set/display to tell you what to do next. The information is already there, I just need to know what your assignments are! :confused: |
Do you mean this mate?
Code:
Div 1 Div 2 Div 3 Div 4 |
Yes, that will help.
Additional question ... Are the images or text associated with the <DIV> tags all the same or do the contents change with the CITY selected? |
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| All times are GMT +1. The time now is 08:05 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.