Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic Filter of ddlistbox

Posted on 2001-06-04
2
Medium Priority
?
174 Views
Last Modified: 2012-08-13
What's the easiest way to filter a Dropdown listbox based on the value of another listbox without having to submit the form?  Is there an easier way than using div statements?

Example:

Listbox A is a list of stores. "S1", "S2", etc...
Listbox B is a list of products for a store "S1P1", "S1P2", "S2P1", S2P2", etc....

I want to retrieve all of the products when the page is accessed but I want to filter the list based on which store is selected in Listbox A.

Thanks
0
Comment
Question by:lavesa
[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 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 150 total points
ID: 6154108
<script>
function setVal(theSel) {
   if (theSel.selectedIndex < 1) return;
   storeSel = theSel.form.store;
   prods = theSel.options[theSel.selectedIndex].value.split('|')
   for (i=0;i<prods.length;i++) {
      storeSel.options[i+1] = new Option(prods[i],prods[i]);
   }
}
</script>
<form>
<select onChange="setVal(this)"><
<option value="">Select store
<option value="P1|P2">Store 1</option>
<option value="P2|P3">Store 2</option>
</select>
<selectname="store">
<option value="">Select Product
<option>__________________</option>
<option>__________________</option>
</select>
</form>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6154113
You can also store the values in arrays and access them directly without using the split method
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 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