html - javascript : mapping same key to different arrays -
i trying populate dropdown(s) on select of option in 1st dropdown(product), using pure java script. got struck @ mapping respective files product, when same version number repeats different products
following data set.
producta => version1.0.0 => filea1.zip producta => version1.0.1 => filea2.zip productb => version3.5.0 => fileb1.zip productb => version4.0.1 => fileb2.zip productc => version1.0.0 => filec1.zip productc => version1.0.1 => filec2.zip
my javascript arrays
var productnamemap = { "producta":["1.0.0","1.0.1"], "productb":["3.5.0","4.0.1"], "productc":["1.0.0","1.0.1"], }; //want map files associated particular product var productseriesmap = { "version1.0.0":["filea1.zip"], "version1.0.1":["filea2.zip"] };
how can differentiate between producta => version1.0.0
, productc => version1.0.0
during mapping ?
my html
<html> <body> product: <select id="product" onchange="changeproduct"> <option>--choose product--</option> </select><br/> version:<select id="version" onchange="changeversion" ></select><br/> file:<select id="file"></select> <script> //have java script here populate dropdowns </script>
have in 1 structure
var productsmap = { "producta":{"1.0.0":"file1-a1.zip","1.0.1":"file-a2.zip"}, "productc":{"1.0.0":"file-c1.zip","1.0.1":"file-c2.zip"}, };
when user select producta have versions , associated files
productsmap.producta
when user select productc have versions , associated files at
productsmap.productc
Comments
Post a Comment