Solved

get value from javascript array

Posted on 2016-08-16
9
42 Views
Last Modified: 2016-08-16
I have a combo that allows user to get the not, now i would like to populate another combo with the scaletype after selecting the note,

tried something simple to get going by showing value in paragraph but its not working.

if i select "C" then return scaletypes for C is the objective

<!DOCTYPE html>
<html>
<body>
    <input type="file" id="fileinput" />
 
<pre id="file"></pre>
    <p>Select The Tonic from the list.</p>

    <select id="mySelect" onchange="myFunction()">
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="C">C</option>
        <option value="D">D</option>
        <option value="E">E</option>
        <option value="F">F</option>
        <option value="G">G</option>
        <option value="Ab">Ab</option>
        <option value="Bb">Bb</option>
        <option value="Db">Db</option>
        <option value="Eb">Eb</option>
        <option value="Gb">Gb</option>
    </select>

  

    <p id="demo"></p>
    <p id="demo2"></p>
    <script>
        var Scales = [{ "Tonic": "C", "ScaleType": "Whole Tone" },
 { "Tonic": "C", "ScaleType": "Minor Blues" },
 { "Tonic": "C", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "C", "ScaleType": "Major Pentatonic" },
 { "Tonic": "C", "ScaleType": "Harmonic Minor" },
 { "Tonic": "C", "ScaleType": "Melodic Minor" },
 { "Tonic": "C", "ScaleType": "Super Locrian" },
 { "Tonic": "C", "ScaleType": "Bhairav" },
 { "Tonic": "C", "ScaleType": "Hungarian Minor" },
 { "Tonic": "C", "ScaleType": "Minor Gypsy" },
 { "Tonic": "C", "ScaleType": "Hirojoshi" },
 { "Tonic": "C", "ScaleType": "In-Sen" },
 { "Tonic": "C", "ScaleType": "Iwato" },
 { "Tonic": "C", "ScaleType": "Kumoi" },
 { "Tonic": "C", "ScaleType": "Pelog" },
 { "Tonic": "C", "ScaleType": "Spanish" },
 { "Tonic": "D", "ScaleType": "Major" },
 { "Tonic": "D", "ScaleType": "Minor" },
 { "Tonic": "D", "ScaleType": "Dorian" },
 { "Tonic": "D", "ScaleType": "Mixolydian" },
 { "Tonic": "D", "ScaleType": "Lydian" },
 { "Tonic": "D", "ScaleType": "Phrygian" },
 { "Tonic": "D", "ScaleType": "Locrian" },
 { "Tonic": "D", "ScaleType": "Diminished" },
 { "Tonic": "D", "ScaleType": "Whole-half" },
 { "Tonic": "D", "ScaleType": "Whole Tone" },
 { "Tonic": "D", "ScaleType": "Minor Blues" },
 { "Tonic": "D", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "D", "ScaleType": "Major Pentatonic" },
 { "Tonic": "D", "ScaleType": "Harmonic Minor" },
 { "Tonic": "D", "ScaleType": "Melodic Minor" },
 { "Tonic": "D", "ScaleType": "Super Locrian" },
 { "Tonic": "D", "ScaleType": "Bhairav" },
 { "Tonic": "D", "ScaleType": "Hungarian Minor" },
 { "Tonic": "D", "ScaleType": "Minor Gypsy" },
 { "Tonic": "D", "ScaleType": "Hirojoshi" },
 { "Tonic": "D", "ScaleType": "In-Sen" },
 { "Tonic": "D", "ScaleType": "Iwato" },
 { "Tonic": "D", "ScaleType": "Kumoi" },
 { "Tonic": "D", "ScaleType": "Pelog" },
 { "Tonic": "D", "ScaleType": "Spanish" },
 { "Tonic": "E", "ScaleType": "Major" },
 { "Tonic": "E", "ScaleType": "Minor" },
 { "Tonic": "E", "ScaleType": "Dorian" },
 { "Tonic": "E", "ScaleType": "Mixolydian" },
 { "Tonic": "E", "ScaleType": "Lydian" },
 { "Tonic": "E", "ScaleType": "Phrygian" },
 { "Tonic": "E", "ScaleType": "Locrian" },
 { "Tonic": "E", "ScaleType": "Diminished" },
 { "Tonic": "E", "ScaleType": "Whole-half" },
 { "Tonic": "E", "ScaleType": "Whole Tone" },
 { "Tonic": "E", "ScaleType": "Minor Blues" },
 { "Tonic": "E", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "E", "ScaleType": "Major Pentatonic" },
 { "Tonic": "E", "ScaleType": "Harmonic Minor" },
 { "Tonic": "E", "ScaleType": "Melodic Minor" },
 { "Tonic": "E", "ScaleType": "Super Locrian" },
 { "Tonic": "E", "ScaleType": "Bhairav" },
 { "Tonic": "E", "ScaleType": "Hungarian Minor" },
 { "Tonic": "E", "ScaleType": "Minor Gypsy" },
 { "Tonic": "E", "ScaleType": "Hirojoshi" },
 { "Tonic": "E", "ScaleType": "In-Sen" },
 { "Tonic": "E", "ScaleType": "Iwato" },
 { "Tonic": "E", "ScaleType": "Kumoi" },
 { "Tonic": "E", "ScaleType": "Pelog" },
 { "Tonic": "E", "ScaleType": "Spanish" },
 { "Tonic": "A", "ScaleType": "Major" },
 { "Tonic": "A", "ScaleType": "Minor" },
 { "Tonic": "A", "ScaleType": "Dorian" },
 { "Tonic": "A", "ScaleType": "Mixolydian" },
 { "Tonic": "A", "ScaleType": "Lydian" },
 { "Tonic": "A", "ScaleType": "Phrygian" },
 { "Tonic": "A", "ScaleType": "Locrian" },
 { "Tonic": "A", "ScaleType": "Diminished" },
 { "Tonic": "A", "ScaleType": "Whole-half" },
 { "Tonic": "A", "ScaleType": "Whole Tone" },
 { "Tonic": "A", "ScaleType": "Minor Blues" },
 { "Tonic": "A", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "A", "ScaleType": "Major Pentatonic" },
 { "Tonic": "A", "ScaleType": "Harmonic Minor" },
 { "Tonic": "A", "ScaleType": "Melodic Minor" },
 { "Tonic": "A", "ScaleType": "Super Locrian" },
 { "Tonic": "A", "ScaleType": "Bhairav" },
 { "Tonic": "A", "ScaleType": "Hungarian Minor" },
 { "Tonic": "A", "ScaleType": "Minor Gypsy" },
 { "Tonic": "A", "ScaleType": "Hirojoshi" },
 { "Tonic": "A", "ScaleType": "In-Sen" },
 { "Tonic": "A", "ScaleType": "Iwato" },
 { "Tonic": "A", "ScaleType": "Kumoi" },
 { "Tonic": "A", "ScaleType": "Pelog" },
 { "Tonic": "A", "ScaleType": "Spanish" },
 { "Tonic": "B", "ScaleType": "Major" },
 { "Tonic": "B", "ScaleType": "Minor" },
 { "Tonic": "B", "ScaleType": "Dorian" },
 { "Tonic": "B", "ScaleType": "Mixolydian" },
 { "Tonic": "B", "ScaleType": "Lydian" },
 { "Tonic": "B", "ScaleType": "Phrygian" },
 { "Tonic": "B", "ScaleType": "Locrian" },
 { "Tonic": "B", "ScaleType": "Diminished" },
 { "Tonic": "B", "ScaleType": "Whole-half" },
 { "Tonic": "B", "ScaleType": "Whole Tone" },
 { "Tonic": "B", "ScaleType": "Minor Blues" },
 { "Tonic": "B", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "B", "ScaleType": "Major Pentatonic" },
 { "Tonic": "B", "ScaleType": "Harmonic Minor" },
 { "Tonic": "B", "ScaleType": "Melodic Minor" },
 { "Tonic": "B", "ScaleType": "Super Locrian" },
 { "Tonic": "B", "ScaleType": "Bhairav" },
 { "Tonic": "B", "ScaleType": "Hungarian Minor" },
 { "Tonic": "B", "ScaleType": "Minor Gypsy" },
 { "Tonic": "B", "ScaleType": "Hirojoshi" },
 { "Tonic": "B", "ScaleType": "In-Sen" },
 { "Tonic": "B", "ScaleType": "Iwato" },
 { "Tonic": "B", "ScaleType": "Kumoi" },
 { "Tonic": "B", "ScaleType": "Pelog" },
 { "Tonic": "B", "ScaleType": "Spanish" },
 { "Tonic": "G", "ScaleType": "Major" },
 { "Tonic": "G", "ScaleType": "Minor" },
 { "Tonic": "G", "ScaleType": "Dorian" },
 { "Tonic": "G", "ScaleType": "Mixolydian" },
 { "Tonic": "G", "ScaleType": "Lydian" },
 { "Tonic": "G", "ScaleType": "Phrygian" },
 { "Tonic": "G", "ScaleType": "Locrian" },
 { "Tonic": "G", "ScaleType": "Diminished" },
 { "Tonic": "G", "ScaleType": "Whole-half" },
 { "Tonic": "G", "ScaleType": "Whole Tone" },
 { "Tonic": "G", "ScaleType": "Minor Blues" },
 { "Tonic": "G", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "G", "ScaleType": "Major Pentatonic" },
 { "Tonic": "G", "ScaleType": "Harmonic Minor" },
 { "Tonic": "G", "ScaleType": "Melodic Minor" },
 { "Tonic": "G", "ScaleType": "Super Locrian" },
 { "Tonic": "G", "ScaleType": "Bhairav" },
 { "Tonic": "G", "ScaleType": "Hungarian Minor" },
 { "Tonic": "G", "ScaleType": "Minor Gypsy" },
 { "Tonic": "G", "ScaleType": "Hirojoshi" },
 { "Tonic": "G", "ScaleType": "In-Sen" },
 { "Tonic": "G", "ScaleType": "Iwato" },
 { "Tonic": "G", "ScaleType": "Kumoi" },
 { "Tonic": "G", "ScaleType": "Pelog" },
 { "Tonic": "G", "ScaleType": "Spanish" },
 { "Tonic": "F", "ScaleType": "Major" },
 { "Tonic": "F", "ScaleType": "Minor" },
 { "Tonic": "F", "ScaleType": "Dorian" },
 { "Tonic": "F", "ScaleType": "Mixolydian" },
 { "Tonic": "F", "ScaleType": "Lydian" },
 { "Tonic": "F", "ScaleType": "Phrygian" },
 { "Tonic": "F", "ScaleType": "Locrian" },
 { "Tonic": "F", "ScaleType": "Diminished" },
 { "Tonic": "F", "ScaleType": "Whole-half" },
 { "Tonic": "F", "ScaleType": "Whole Tone" },
 { "Tonic": "F", "ScaleType": "Minor Blues" },
 { "Tonic": "F", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "F", "ScaleType": "Major Pentatonic" },
 { "Tonic": "F", "ScaleType": "Harmonic Minor" },
 { "Tonic": "F", "ScaleType": "Melodic Minor" },
 { "Tonic": "F", "ScaleType": "Super Locrian" },
 { "Tonic": "F", "ScaleType": "Bhairav" },
 { "Tonic": "F", "ScaleType": "Hungarian Minor" },
 { "Tonic": "F", "ScaleType": "Minor Gypsy" },
 { "Tonic": "F", "ScaleType": "Hirojoshi" },
 { "Tonic": "F", "ScaleType": "In-Sen" },
 { "Tonic": "F", "ScaleType": "Iwato" },
 { "Tonic": "F", "ScaleType": "Kumoi" },
 { "Tonic": "F", "ScaleType": "Pelog" },
 { "Tonic": "F", "ScaleType": "Spanish" },
 { "Tonic": "Bb", "ScaleType": "Major" },
 { "Tonic": "Bb", "ScaleType": "Minor" },
 { "Tonic": "Bb", "ScaleType": "Dorian" },
 { "Tonic": "Bb", "ScaleType": "Mixolydian" },
 { "Tonic": "Bb", "ScaleType": "Lydian" },
 { "Tonic": "Bb", "ScaleType": "Phrygian" },
 { "Tonic": "Bb", "ScaleType": "Locrian" },
 { "Tonic": "Bb", "ScaleType": "Diminished" },
 { "Tonic": "Bb", "ScaleType": "Whole-half" },
 { "Tonic": "Bb", "ScaleType": "Whole Tone" },
 { "Tonic": "Bb", "ScaleType": "Minor Blues" },
 { "Tonic": "Bb", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Bb", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Bb", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Bb", "ScaleType": "Melodic Minor" },
 { "Tonic": "Bb", "ScaleType": "Super Locrian" },
 { "Tonic": "Bb", "ScaleType": "Bhairav" },
 { "Tonic": "Bb", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Bb", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Bb", "ScaleType": "Hirojoshi" },
 { "Tonic": "Bb", "ScaleType": "In-Sen" },
 { "Tonic": "Bb", "ScaleType": "Iwato" },
 { "Tonic": "Bb", "ScaleType": "Kumoi" },
 { "Tonic": "Bb", "ScaleType": "Pelog" },
 { "Tonic": "Bb", "ScaleType": "Spanish" },
 { "Tonic": "Eb", "ScaleType": "Major" },
 { "Tonic": "Eb", "ScaleType": "Minor" },
 { "Tonic": "Eb", "ScaleType": "Dorian" },
 { "Tonic": "Eb", "ScaleType": "Mixolydian" },
 { "Tonic": "Eb", "ScaleType": "Lydian" },
 { "Tonic": "Eb", "ScaleType": "Phrygian" },
 { "Tonic": "Eb", "ScaleType": "Locrian" },
 { "Tonic": "Eb", "ScaleType": "Diminished" },
 { "Tonic": "Eb", "ScaleType": "Whole-half" },
 { "Tonic": "Eb", "ScaleType": "Whole Tone" },
 { "Tonic": "Eb", "ScaleType": "Minor Blues" },
 { "Tonic": "Eb", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Eb", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Eb", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Eb", "ScaleType": "Melodic Minor" },
 { "Tonic": "Eb", "ScaleType": "Super Locrian" },
 { "Tonic": "Eb", "ScaleType": "Bhairav" },
 { "Tonic": "Eb", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Eb", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Eb", "ScaleType": "Hirojoshi" },
 { "Tonic": "Eb", "ScaleType": "In-Sen" },
 { "Tonic": "Eb", "ScaleType": "Iwato" },
 { "Tonic": "Eb", "ScaleType": "Kumoi" },
 { "Tonic": "Eb", "ScaleType": "Pelog" },
 { "Tonic": "Eb", "ScaleType": "Spanish" },
 { "Tonic": "Ab", "ScaleType": "Major" },
 { "Tonic": "Ab", "ScaleType": "Minor" },
 { "Tonic": "Ab", "ScaleType": "Dorian" },
 { "Tonic": "Ab", "ScaleType": "Mixolydian" },
 { "Tonic": "Ab", "ScaleType": "Lydian" },
 { "Tonic": "Ab", "ScaleType": "Phrygian" },
 { "Tonic": "Ab", "ScaleType": "Locrian" },
 { "Tonic": "Ab", "ScaleType": "Diminished" },
 { "Tonic": "Ab", "ScaleType": "Whole-half" },
 { "Tonic": "Ab", "ScaleType": "Whole Tone" },
 { "Tonic": "Ab", "ScaleType": "Minor Blues" },
 { "Tonic": "Ab", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Ab", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Ab", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Ab", "ScaleType": "Melodic Minor" },
 { "Tonic": "Ab", "ScaleType": "Super Locrian" },
 { "Tonic": "Ab", "ScaleType": "Bhairav" },
 { "Tonic": "Ab", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Ab", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Ab", "ScaleType": "Hirojoshi" },
 { "Tonic": "Ab", "ScaleType": "In-Sen" },
 { "Tonic": "Ab", "ScaleType": "Iwato" },
 { "Tonic": "Ab", "ScaleType": "Kumoi" },
 { "Tonic": "Ab", "ScaleType": "Pelog" },
 { "Tonic": "Ab", "ScaleType": "Spanish" },
 { "Tonic": "Db", "ScaleType": "Major" },
 { "Tonic": "Db", "ScaleType": "Minor" },
 { "Tonic": "Db", "ScaleType": "Dorian" },
 { "Tonic": "Db", "ScaleType": "Mixolydian" },
 { "Tonic": "Db", "ScaleType": "Lydian" },
 { "Tonic": "Db", "ScaleType": "Phrygian" },
 { "Tonic": "Db", "ScaleType": "Locrian" },
 { "Tonic": "Db", "ScaleType": "Diminished" },
 { "Tonic": "Db", "ScaleType": "Whole-half" },
 { "Tonic": "Db", "ScaleType": "Whole Tone" },
 { "Tonic": "Db", "ScaleType": "Minor Blues" },
 { "Tonic": "Db", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Db", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Db", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Db", "ScaleType": "Melodic Minor" },
 { "Tonic": "Db", "ScaleType": "Super Locrian" },
 { "Tonic": "Db", "ScaleType": "Bhairav" },
 { "Tonic": "Db", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Db", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Db", "ScaleType": "Hirojoshi" },
 { "Tonic": "Db", "ScaleType": "In-Sen" },
 { "Tonic": "Db", "ScaleType": "Iwato" },
 { "Tonic": "Db", "ScaleType": "Kumoi" },
 { "Tonic": "Db", "ScaleType": "Pelog" },
 { "Tonic": "Db", "ScaleType": "Spanish" },
 { "Tonic": "Gb", "ScaleType": "Major" },
 { "Tonic": "Gb", "ScaleType": "Minor" },
 { "Tonic": "Gb", "ScaleType": "Dorian" },
 { "Tonic": "Gb", "ScaleType": "Mixolydian" },
 { "Tonic": "Gb", "ScaleType": "Lydian" },
 { "Tonic": "Gb", "ScaleType": "Phrygian" },
 { "Tonic": "Gb", "ScaleType": "Locrian" },
 { "Tonic": "Gb", "ScaleType": "Diminished" },
 { "Tonic": "Gb", "ScaleType": "Whole-half" },
 { "Tonic": "Gb", "ScaleType": "Whole Tone" },
 { "Tonic": "Gb", "ScaleType": "Minor Blues" },
 { "Tonic": "Gb", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Gb", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Gb", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Gb", "ScaleType": "Melodic Minor" },
 { "Tonic": "Gb", "ScaleType": "Super Locrian" },
 { "Tonic": "Gb", "ScaleType": "Bhairav" },
 { "Tonic": "Gb", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Gb", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Gb", "ScaleType": "Hirojoshi" },
 { "Tonic": "Gb", "ScaleType": "In-Sen" },
 { "Tonic": "Gb", "ScaleType": "Iwato" },
 { "Tonic": "Gb", "ScaleType": "Kumoi" },
 { "Tonic": "Gb", "ScaleType": "Pelog" },
 { "Tonic": "Gb", "ScaleType": "Spanish" }]

        function myFunction() {
            var x = document.getElementById("mySelect").value;
            document.getElementById("demo").innerHTML = "You selected: " + x;
            document.getElementById("demo2").innerHTML = Scales.find(x);
        }








</script>

</body>
</html>

Open in new window

0
Comment
Question by:PeterBaileyUk
  • 6
  • 3
9 Comments
 
LVL 51

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
Comment Utility
There are many ways to do this.

First way - as you have it using JQuery.
HTML
    <select id="mySelect">
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="C">C</option>
        <option value="D">D</option>
        <option value="E">E</option>
        <option value="F">F</option>
        <option value="G">G</option>
        <option value="Ab">Ab</option>
        <option value="Bb">Bb</option>
        <option value="Db">Db</option>
        <option value="Eb">Eb</option>
        <option value="Gb">Gb</option>
    </select>
  <select id="scaletype">
  </select>

Open in new window

JQuery
<script src="http://code.jquery.com/jquery.js"></script>  
<script src="js\scales.js"></script>
<script>
$(function() {
  $('#mySelect').change(function() {
    var sel = $(this).val();
    $('#scaletype').empty();
    $.each(Scales, function(i,e) {
      if (e.Tonic == sel) {
        $('#scaletype').append(
          $('<option/>').html(e.ScaleType).val(e.ScaleType)
        );
      }
    });
  });
});
</script>

Open in new window

In the above code there are a few things to note
1. I have moved the data off into a separate JS file
2. I have included the JQuery library
Working sample here
In the next post I will show a different method using restructured data.
EDIT - Adding Scales.js
var Scales = [{ "Tonic": "C", "ScaleType": "Whole Tone" },
 { "Tonic": "C", "ScaleType": "Minor Blues" },
 { "Tonic": "C", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "C", "ScaleType": "Major Pentatonic" },
 { "Tonic": "C", "ScaleType": "Harmonic Minor" },
 { "Tonic": "C", "ScaleType": "Melodic Minor" },
 { "Tonic": "C", "ScaleType": "Super Locrian" },
 { "Tonic": "C", "ScaleType": "Bhairav" },
 { "Tonic": "C", "ScaleType": "Hungarian Minor" },
 { "Tonic": "C", "ScaleType": "Minor Gypsy" },
 { "Tonic": "C", "ScaleType": "Hirojoshi" },
 { "Tonic": "C", "ScaleType": "In-Sen" },
 { "Tonic": "C", "ScaleType": "Iwato" },
 { "Tonic": "C", "ScaleType": "Kumoi" },
 { "Tonic": "C", "ScaleType": "Pelog" },
 { "Tonic": "C", "ScaleType": "Spanish" },
 { "Tonic": "D", "ScaleType": "Major" },
 { "Tonic": "D", "ScaleType": "Minor" },
 { "Tonic": "D", "ScaleType": "Dorian" },
 { "Tonic": "D", "ScaleType": "Mixolydian" },
 { "Tonic": "D", "ScaleType": "Lydian" },
 { "Tonic": "D", "ScaleType": "Phrygian" },
 { "Tonic": "D", "ScaleType": "Locrian" },
 { "Tonic": "D", "ScaleType": "Diminished" },
 { "Tonic": "D", "ScaleType": "Whole-half" },
 { "Tonic": "D", "ScaleType": "Whole Tone" },
 { "Tonic": "D", "ScaleType": "Minor Blues" },
 { "Tonic": "D", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "D", "ScaleType": "Major Pentatonic" },
 { "Tonic": "D", "ScaleType": "Harmonic Minor" },
 { "Tonic": "D", "ScaleType": "Melodic Minor" },
 { "Tonic": "D", "ScaleType": "Super Locrian" },
 { "Tonic": "D", "ScaleType": "Bhairav" },
 { "Tonic": "D", "ScaleType": "Hungarian Minor" },
 { "Tonic": "D", "ScaleType": "Minor Gypsy" },
 { "Tonic": "D", "ScaleType": "Hirojoshi" },
 { "Tonic": "D", "ScaleType": "In-Sen" },
 { "Tonic": "D", "ScaleType": "Iwato" },
 { "Tonic": "D", "ScaleType": "Kumoi" },
 { "Tonic": "D", "ScaleType": "Pelog" },
 { "Tonic": "D", "ScaleType": "Spanish" },
 { "Tonic": "E", "ScaleType": "Major" },
 { "Tonic": "E", "ScaleType": "Minor" },
 { "Tonic": "E", "ScaleType": "Dorian" },
 { "Tonic": "E", "ScaleType": "Mixolydian" },
 { "Tonic": "E", "ScaleType": "Lydian" },
 { "Tonic": "E", "ScaleType": "Phrygian" },
 { "Tonic": "E", "ScaleType": "Locrian" },
 { "Tonic": "E", "ScaleType": "Diminished" },
 { "Tonic": "E", "ScaleType": "Whole-half" },
 { "Tonic": "E", "ScaleType": "Whole Tone" },
 { "Tonic": "E", "ScaleType": "Minor Blues" },
 { "Tonic": "E", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "E", "ScaleType": "Major Pentatonic" },
 { "Tonic": "E", "ScaleType": "Harmonic Minor" },
 { "Tonic": "E", "ScaleType": "Melodic Minor" },
 { "Tonic": "E", "ScaleType": "Super Locrian" },
 { "Tonic": "E", "ScaleType": "Bhairav" },
 { "Tonic": "E", "ScaleType": "Hungarian Minor" },
 { "Tonic": "E", "ScaleType": "Minor Gypsy" },
 { "Tonic": "E", "ScaleType": "Hirojoshi" },
 { "Tonic": "E", "ScaleType": "In-Sen" },
 { "Tonic": "E", "ScaleType": "Iwato" },
 { "Tonic": "E", "ScaleType": "Kumoi" },
 { "Tonic": "E", "ScaleType": "Pelog" },
 { "Tonic": "E", "ScaleType": "Spanish" },
 { "Tonic": "A", "ScaleType": "Major" },
 { "Tonic": "A", "ScaleType": "Minor" },
 { "Tonic": "A", "ScaleType": "Dorian" },
 { "Tonic": "A", "ScaleType": "Mixolydian" },
 { "Tonic": "A", "ScaleType": "Lydian" },
 { "Tonic": "A", "ScaleType": "Phrygian" },
 { "Tonic": "A", "ScaleType": "Locrian" },
 { "Tonic": "A", "ScaleType": "Diminished" },
 { "Tonic": "A", "ScaleType": "Whole-half" },
 { "Tonic": "A", "ScaleType": "Whole Tone" },
 { "Tonic": "A", "ScaleType": "Minor Blues" },
 { "Tonic": "A", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "A", "ScaleType": "Major Pentatonic" },
 { "Tonic": "A", "ScaleType": "Harmonic Minor" },
 { "Tonic": "A", "ScaleType": "Melodic Minor" },
 { "Tonic": "A", "ScaleType": "Super Locrian" },
 { "Tonic": "A", "ScaleType": "Bhairav" },
 { "Tonic": "A", "ScaleType": "Hungarian Minor" },
 { "Tonic": "A", "ScaleType": "Minor Gypsy" },
 { "Tonic": "A", "ScaleType": "Hirojoshi" },
 { "Tonic": "A", "ScaleType": "In-Sen" },
 { "Tonic": "A", "ScaleType": "Iwato" },
 { "Tonic": "A", "ScaleType": "Kumoi" },
 { "Tonic": "A", "ScaleType": "Pelog" },
 { "Tonic": "A", "ScaleType": "Spanish" },
 { "Tonic": "B", "ScaleType": "Major" },
 { "Tonic": "B", "ScaleType": "Minor" },
 { "Tonic": "B", "ScaleType": "Dorian" },
 { "Tonic": "B", "ScaleType": "Mixolydian" },
 { "Tonic": "B", "ScaleType": "Lydian" },
 { "Tonic": "B", "ScaleType": "Phrygian" },
 { "Tonic": "B", "ScaleType": "Locrian" },
 { "Tonic": "B", "ScaleType": "Diminished" },
 { "Tonic": "B", "ScaleType": "Whole-half" },
 { "Tonic": "B", "ScaleType": "Whole Tone" },
 { "Tonic": "B", "ScaleType": "Minor Blues" },
 { "Tonic": "B", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "B", "ScaleType": "Major Pentatonic" },
 { "Tonic": "B", "ScaleType": "Harmonic Minor" },
 { "Tonic": "B", "ScaleType": "Melodic Minor" },
 { "Tonic": "B", "ScaleType": "Super Locrian" },
 { "Tonic": "B", "ScaleType": "Bhairav" },
 { "Tonic": "B", "ScaleType": "Hungarian Minor" },
 { "Tonic": "B", "ScaleType": "Minor Gypsy" },
 { "Tonic": "B", "ScaleType": "Hirojoshi" },
 { "Tonic": "B", "ScaleType": "In-Sen" },
 { "Tonic": "B", "ScaleType": "Iwato" },
 { "Tonic": "B", "ScaleType": "Kumoi" },
 { "Tonic": "B", "ScaleType": "Pelog" },
 { "Tonic": "B", "ScaleType": "Spanish" },
 { "Tonic": "G", "ScaleType": "Major" },
 { "Tonic": "G", "ScaleType": "Minor" },
 { "Tonic": "G", "ScaleType": "Dorian" },
 { "Tonic": "G", "ScaleType": "Mixolydian" },
 { "Tonic": "G", "ScaleType": "Lydian" },
 { "Tonic": "G", "ScaleType": "Phrygian" },
 { "Tonic": "G", "ScaleType": "Locrian" },
 { "Tonic": "G", "ScaleType": "Diminished" },
 { "Tonic": "G", "ScaleType": "Whole-half" },
 { "Tonic": "G", "ScaleType": "Whole Tone" },
 { "Tonic": "G", "ScaleType": "Minor Blues" },
 { "Tonic": "G", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "G", "ScaleType": "Major Pentatonic" },
 { "Tonic": "G", "ScaleType": "Harmonic Minor" },
 { "Tonic": "G", "ScaleType": "Melodic Minor" },
 { "Tonic": "G", "ScaleType": "Super Locrian" },
 { "Tonic": "G", "ScaleType": "Bhairav" },
 { "Tonic": "G", "ScaleType": "Hungarian Minor" },
 { "Tonic": "G", "ScaleType": "Minor Gypsy" },
 { "Tonic": "G", "ScaleType": "Hirojoshi" },
 { "Tonic": "G", "ScaleType": "In-Sen" },
 { "Tonic": "G", "ScaleType": "Iwato" },
 { "Tonic": "G", "ScaleType": "Kumoi" },
 { "Tonic": "G", "ScaleType": "Pelog" },
 { "Tonic": "G", "ScaleType": "Spanish" },
 { "Tonic": "F", "ScaleType": "Major" },
 { "Tonic": "F", "ScaleType": "Minor" },
 { "Tonic": "F", "ScaleType": "Dorian" },
 { "Tonic": "F", "ScaleType": "Mixolydian" },
 { "Tonic": "F", "ScaleType": "Lydian" },
 { "Tonic": "F", "ScaleType": "Phrygian" },
 { "Tonic": "F", "ScaleType": "Locrian" },
 { "Tonic": "F", "ScaleType": "Diminished" },
 { "Tonic": "F", "ScaleType": "Whole-half" },
 { "Tonic": "F", "ScaleType": "Whole Tone" },
 { "Tonic": "F", "ScaleType": "Minor Blues" },
 { "Tonic": "F", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "F", "ScaleType": "Major Pentatonic" },
 { "Tonic": "F", "ScaleType": "Harmonic Minor" },
 { "Tonic": "F", "ScaleType": "Melodic Minor" },
 { "Tonic": "F", "ScaleType": "Super Locrian" },
 { "Tonic": "F", "ScaleType": "Bhairav" },
 { "Tonic": "F", "ScaleType": "Hungarian Minor" },
 { "Tonic": "F", "ScaleType": "Minor Gypsy" },
 { "Tonic": "F", "ScaleType": "Hirojoshi" },
 { "Tonic": "F", "ScaleType": "In-Sen" },
 { "Tonic": "F", "ScaleType": "Iwato" },
 { "Tonic": "F", "ScaleType": "Kumoi" },
 { "Tonic": "F", "ScaleType": "Pelog" },
 { "Tonic": "F", "ScaleType": "Spanish" },
 { "Tonic": "Bb", "ScaleType": "Major" },
 { "Tonic": "Bb", "ScaleType": "Minor" },
 { "Tonic": "Bb", "ScaleType": "Dorian" },
 { "Tonic": "Bb", "ScaleType": "Mixolydian" },
 { "Tonic": "Bb", "ScaleType": "Lydian" },
 { "Tonic": "Bb", "ScaleType": "Phrygian" },
 { "Tonic": "Bb", "ScaleType": "Locrian" },
 { "Tonic": "Bb", "ScaleType": "Diminished" },
 { "Tonic": "Bb", "ScaleType": "Whole-half" },
 { "Tonic": "Bb", "ScaleType": "Whole Tone" },
 { "Tonic": "Bb", "ScaleType": "Minor Blues" },
 { "Tonic": "Bb", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Bb", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Bb", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Bb", "ScaleType": "Melodic Minor" },
 { "Tonic": "Bb", "ScaleType": "Super Locrian" },
 { "Tonic": "Bb", "ScaleType": "Bhairav" },
 { "Tonic": "Bb", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Bb", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Bb", "ScaleType": "Hirojoshi" },
 { "Tonic": "Bb", "ScaleType": "In-Sen" },
 { "Tonic": "Bb", "ScaleType": "Iwato" },
 { "Tonic": "Bb", "ScaleType": "Kumoi" },
 { "Tonic": "Bb", "ScaleType": "Pelog" },
 { "Tonic": "Bb", "ScaleType": "Spanish" },
 { "Tonic": "Eb", "ScaleType": "Major" },
 { "Tonic": "Eb", "ScaleType": "Minor" },
 { "Tonic": "Eb", "ScaleType": "Dorian" },
 { "Tonic": "Eb", "ScaleType": "Mixolydian" },
 { "Tonic": "Eb", "ScaleType": "Lydian" },
 { "Tonic": "Eb", "ScaleType": "Phrygian" },
 { "Tonic": "Eb", "ScaleType": "Locrian" },
 { "Tonic": "Eb", "ScaleType": "Diminished" },
 { "Tonic": "Eb", "ScaleType": "Whole-half" },
 { "Tonic": "Eb", "ScaleType": "Whole Tone" },
 { "Tonic": "Eb", "ScaleType": "Minor Blues" },
 { "Tonic": "Eb", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Eb", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Eb", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Eb", "ScaleType": "Melodic Minor" },
 { "Tonic": "Eb", "ScaleType": "Super Locrian" },
 { "Tonic": "Eb", "ScaleType": "Bhairav" },
 { "Tonic": "Eb", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Eb", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Eb", "ScaleType": "Hirojoshi" },
 { "Tonic": "Eb", "ScaleType": "In-Sen" },
 { "Tonic": "Eb", "ScaleType": "Iwato" },
 { "Tonic": "Eb", "ScaleType": "Kumoi" },
 { "Tonic": "Eb", "ScaleType": "Pelog" },
 { "Tonic": "Eb", "ScaleType": "Spanish" },
 { "Tonic": "Ab", "ScaleType": "Major" },
 { "Tonic": "Ab", "ScaleType": "Minor" },
 { "Tonic": "Ab", "ScaleType": "Dorian" },
 { "Tonic": "Ab", "ScaleType": "Mixolydian" },
 { "Tonic": "Ab", "ScaleType": "Lydian" },
 { "Tonic": "Ab", "ScaleType": "Phrygian" },
 { "Tonic": "Ab", "ScaleType": "Locrian" },
 { "Tonic": "Ab", "ScaleType": "Diminished" },
 { "Tonic": "Ab", "ScaleType": "Whole-half" },
 { "Tonic": "Ab", "ScaleType": "Whole Tone" },
 { "Tonic": "Ab", "ScaleType": "Minor Blues" },
 { "Tonic": "Ab", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Ab", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Ab", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Ab", "ScaleType": "Melodic Minor" },
 { "Tonic": "Ab", "ScaleType": "Super Locrian" },
 { "Tonic": "Ab", "ScaleType": "Bhairav" },
 { "Tonic": "Ab", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Ab", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Ab", "ScaleType": "Hirojoshi" },
 { "Tonic": "Ab", "ScaleType": "In-Sen" },
 { "Tonic": "Ab", "ScaleType": "Iwato" },
 { "Tonic": "Ab", "ScaleType": "Kumoi" },
 { "Tonic": "Ab", "ScaleType": "Pelog" },
 { "Tonic": "Ab", "ScaleType": "Spanish" },
 { "Tonic": "Db", "ScaleType": "Major" },
 { "Tonic": "Db", "ScaleType": "Minor" },
 { "Tonic": "Db", "ScaleType": "Dorian" },
 { "Tonic": "Db", "ScaleType": "Mixolydian" },
 { "Tonic": "Db", "ScaleType": "Lydian" },
 { "Tonic": "Db", "ScaleType": "Phrygian" },
 { "Tonic": "Db", "ScaleType": "Locrian" },
 { "Tonic": "Db", "ScaleType": "Diminished" },
 { "Tonic": "Db", "ScaleType": "Whole-half" },
 { "Tonic": "Db", "ScaleType": "Whole Tone" },
 { "Tonic": "Db", "ScaleType": "Minor Blues" },
 { "Tonic": "Db", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Db", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Db", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Db", "ScaleType": "Melodic Minor" },
 { "Tonic": "Db", "ScaleType": "Super Locrian" },
 { "Tonic": "Db", "ScaleType": "Bhairav" },
 { "Tonic": "Db", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Db", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Db", "ScaleType": "Hirojoshi" },
 { "Tonic": "Db", "ScaleType": "In-Sen" },
 { "Tonic": "Db", "ScaleType": "Iwato" },
 { "Tonic": "Db", "ScaleType": "Kumoi" },
 { "Tonic": "Db", "ScaleType": "Pelog" },
 { "Tonic": "Db", "ScaleType": "Spanish" },
 { "Tonic": "Gb", "ScaleType": "Major" },
 { "Tonic": "Gb", "ScaleType": "Minor" },
 { "Tonic": "Gb", "ScaleType": "Dorian" },
 { "Tonic": "Gb", "ScaleType": "Mixolydian" },
 { "Tonic": "Gb", "ScaleType": "Lydian" },
 { "Tonic": "Gb", "ScaleType": "Phrygian" },
 { "Tonic": "Gb", "ScaleType": "Locrian" },
 { "Tonic": "Gb", "ScaleType": "Diminished" },
 { "Tonic": "Gb", "ScaleType": "Whole-half" },
 { "Tonic": "Gb", "ScaleType": "Whole Tone" },
 { "Tonic": "Gb", "ScaleType": "Minor Blues" },
 { "Tonic": "Gb", "ScaleType": "Minor Pentatonic" },
 { "Tonic": "Gb", "ScaleType": "Major Pentatonic" },
 { "Tonic": "Gb", "ScaleType": "Harmonic Minor" },
 { "Tonic": "Gb", "ScaleType": "Melodic Minor" },
 { "Tonic": "Gb", "ScaleType": "Super Locrian" },
 { "Tonic": "Gb", "ScaleType": "Bhairav" },
 { "Tonic": "Gb", "ScaleType": "Hungarian Minor" },
 { "Tonic": "Gb", "ScaleType": "Minor Gypsy" },
 { "Tonic": "Gb", "ScaleType": "Hirojoshi" },
 { "Tonic": "Gb", "ScaleType": "In-Sen" },
 { "Tonic": "Gb", "ScaleType": "Iwato" },
 { "Tonic": "Gb", "ScaleType": "Kumoi" },
 { "Tonic": "Gb", "ScaleType": "Pelog" },
 { "Tonic": "Gb", "ScaleType": "Spanish" }]

Open in new window

0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
Option 2 is based on restructuring the data - if this is not possible then it does not really matter as the data set is small, I am providing this for interest

Scales2.js
var Scales = {
  "C":[
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"
  ],
  "D":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "E":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "A":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "B":["Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "G":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "F":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "Bb":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "Eb":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "Ab":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "Db":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"],
  "Gb":[
    "Major",
    "Minor",
    "Dorian",
    "Mixolydian",
    "Lydian",
    "Phrygian",
    "Locrian",
    "Diminished",
    "Whole-half",
    "Whole Tone",
    "Minor Blues",
    "Minor Pentatonic",
    "Major Pentatonic",
    "Harmonic Minor",
    "Melodic Minor",
    "Super Locrian",
    "Bhairav",
    "Hungarian Minor",
    "Minor Gypsy",
    "Hirojoshi",
    "In-Sen",
    "Iwato",
    "Kumoi",
    "Pelog",
    "Spanish"]
}

Open in new window

HTML - same as above
JQuery
<script src="http://code.jquery.com/jquery.js"></script>  
<script src="js\scales2.js"></script>
<script>
$(function() {
  $('#mySelect').change(function() {
    var sel = $(this).val();
    $('#scaletype').empty();
    if (Scales[sel]) {
      $.each(Scales[sel], function(i,e) {
        $('#scaletype').append(
          $('<option/>').html(e).val(e)
        );
      });
    }
  });
});
</script>

Open in new window

The main difference between this version and the previous one is that we can index into the array based on the first selection - we then have access to all the options for that selection without having to iterate through the entire set of options.
0
 

Author Comment

by:PeterBaileyUk
Comment Utility
this is why searching online doesnt help, that is really thorough I will practice each way. the small dataset is in sqlserver but I dont want to access it that way, all i did was convert it xml in sqlserver then i used a find and replace to create the text file.

this gets me over that hurdle.
how do i close off do i just pick the last one as best  as to me they are all best.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You can either pick the best or split - it is up to you.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Closing Comment

by:PeterBaileyUk
Comment Utility
such a great way thank you.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are most welcome.
0
 

Author Comment

by:PeterBaileyUk
Comment Utility
does the reference path always stay the same ie it will find scales.js mine cannot find it.
  <script src="js\scales.js"></script>
ee.JPG
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
the path is relative to the parent file - so for that line to work you would need a subfolder off the folder that the main html file is in called js

In other words
<root>
   index.html
   <js>
       scales.js

Open in new window

You can play with the paths to suit you - it does not have to be structured like that - you could put the js file in the same folder as the main html file and then just do

<script src="scales.js"></script>

Open in new window

It is up to you.
Be careful of case though - Linux systems are case sensitive so you need to match it exactly.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You can also put an absolute path in - for instance if it is on a server you could do

<script src="http://mydomain.com/somepath/js/scales.js"></script>

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now