Solved

Dynamic Filter of ddlistbox

Posted on 2001-06-04
2
161 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 50 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

691 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