Solved

dynamic change in combo box

Posted on 2008-10-07
5
1,578 Views
Last Modified: 2011-10-19
Hi,

      How is it possible to change one combo box based on a change in another. example. One combo box has list of months. the second reflects the holidays in that month. if february then the second combobox will reflect all holidays in that month.

BRgds,

kNish
0
Comment
Question by:eyeqube
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:mverschoof
ID: 22659281
I don't know where you get the holidays fromk, or if you just want to hard code them.

The easiest way is to use display. Try the following. I tested the page and it works.
<html>
<head>
<script type="text/javascript">
var shown = "none";
 
function showMonth(which)
{
  if(which != shown) {
    document.getElementById(which).style.display = "block";
    if(shown != "none") {
      document.getElementById(shown).style.display = "none";
    }
    else {
      // do nothing
    }
    shown = which;
  }
}
</script>
</head>
<body>
 
<select onchange="showMonth(this.value)">
  <option value="january">January</option>
  <option value="february">February</option>
</select>
 
<select id="january" style="display:none;">
  <option>option 1</option>
  <option>option 2</option>
</select>
 
<select id="february" style="display:none;">
  <option>option 3</option>
  <option>option 4</option>
</select>
 
</body>
</html>

Open in new window

0
 
LVL 4

Accepted Solution

by:
Finec earned 250 total points
ID: 22659370
In this way?
<select id="months" multiple="multiple" onchange="get_holidays(this)">
  <option value="1">January</option>
  <option value="2">February</option>
  <option value="3">March</option>
</select>
 
<select id="holidays" multiple="multiple" size="5">
</select>
 
<script type="text/javascript">
 
var holiday = new Array();
 
var january = new Array();
january[1] = "New Year";
january[4] = "4th of January";
//....
holiday[1] = january;
 
var february = new Array();
february[12] = "12th of February"
//...
holiday[2] = february;
 
var march = new Array();
march[28] = "28th of March"
//...
holiday[3] = march;
 
function get_holidays(select)
{
 
  var holidays = document.getElementById('holidays');
  holidays.options.length = 0;
  
  for(var i=0; i<select.options.length; i++)
  {
    if(select.options[i].selected)
    {
      for(var j=0; j<=31; j++)
      {
        var tempMonth = holiday[select.options[i].value];
        if(tempMonth[j])
        {
          var option = document.createElement('option');
          option.text = holiday[select.options[i].value][j];
          holidays.appendChild(option);
        }
      }
    }
  }
  
}
 
</script>

Open in new window

0
 

Author Comment

by:eyeqube
ID: 22668196
Hi,

           mverschoof: you have said it right. However, I consider that the data is coming from tables. how is it possible to get that table data to reflect in the combo box.


bRgds,

kNish
0
 
LVL 5

Assisted Solution

by:mverschoof
mverschoof earned 250 total points
ID: 22676166
Can you be more specific? maybe give an example or something
0
 

Author Comment

by:eyeqube
ID: 22701525
Hi,

         Find attached with this mail an image. Specifically, when one combo box displays the sequence name, the second combo box should display its relevant shots based on the sequence id. This is a stored in a table.


BRgds,

kNish
sequence-shot-link.JPG
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question