We help IT Professionals succeed at work.

Dynamically changing the values in a drop down list in Visual Studio / Visual Web Developer

I have two drop down boxes.

DDAccomm & DDPrice

DDAccomm is bound to my database and gets it's values from a table.

DDPrice is hard coded

I want DDAccomm to change the values of DDPrice according to what is selected

e.g. If then selection of DDaccomm is position 1 or 2 then leave, if it's position 3 or 4 then change the values.  These values are not to come from the DB.

Comment
Watch Question

As you know what the values will be, you can store them in arrays, and use CSS to show/hide them as required:

<html>
<head>
<script type="text/javascript">
var odd = new Array("one", "three", "five");
var even = new Array("two", "four");

function hide(numberType) {
      for (var i=0; i<numberType.length; i++) {
            document.getElementById(numberType[i]).style.display = "none";
      }
}
function show(numberType) {
      for (var i=0; i<numberType.length; i++) {
            document.getElementById(numberType[i]).style.display = "block";
      }
}
</script>
</head>
<body>
<p>Show <a href="#" onclick="hide(even); show(odd); return false;">odd numbers</a>.</p>
<p>Show <a href="#" onclick="hide(odd); show(even); return false;">even numbers</a>.</p>
<select>
      <option id="one">1</option>
      <option id="two">2</option>
      <option id="three">3</option>
      <option id="four">4</option>
      <option id="five">5</option>
</select>
</body>
</html>

J

Author

Commented:
i used on selected index change although this solution would have worked too

Explore More ContentExplore courses, solutions, and other research materials related to this topic.