mardi 26 août 2014

applying a filter to a select box using jQuery


Vote count:

0




I have a webpage which has two <select> boxes: Hadoop Distribution and Hadoop Version. I also have a map between the Distribution and the Version:



function hadoop_map() {
var hash = Object();
// replace this part of the code by a jQuery post
hash['Cloudera'] = ['4', '5'];
hash['Apache'] = ['2.4', '2.3.0', '2.2.0', '2.1.1', '2.1.0', '2.0.6', '1.2.1'];
hash['Hortonworks'] = ['2.1', '2.0', '1.3'];
hash['Pivotal'] = [];
hash['MapR'] = [];

return hash;
}


so, one select is:



<select id="hadoop_dist">
<option>Cloudera</option>
<option>Hortonworks</option>
<option>Apache</option>
<option>MapR</option
<option>Pivotal</option>
</select>


while the other is



<select id="hadoop_version">
<option>4</option>
<option>5</option>
<option>2.3.0</option>
...
</select>


So, when I select Cloudera in the top box, I would like to only display the entries listed in the hadoop_map (i.e 4 and 5) in the hadoop_version ? How can I accomplish that using jQuery?



asked 38 secs ago

philippe

1,969






applying a filter to a select box using jQuery

Aucun commentaire:

Enregistrer un commentaire