I am using HTML & javascript to get the dependent dropdowns. But not able to get the expected results. Can anyone help me out & reviews my code?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
var typeObject = {
  "1": {
    "a",
    "b",
    "c"
  },
  
  "2": {
    "d",
    "e",
    "f",
    "g",
    "h"
  }
}
window.onload = function() {
  var typeSel = document.getElementById("Type");
  var caseReasonSel = document.getElementById("Case_Reason");
  
  for (var x in typeObject) {
    typeSel.options[typeSel.options.length] = new Option(x, x);
  }
  
typeSel.onchange = function() {
    caseReasonSel.length = 1;
    var y = typeObject[typeSel.value][this.value];
    for (var i = 0; i < y.length; i++) {
      typeSel.options[typeSel.options.length] = new Option(y[i], y[i]);
    }
  
}
</script>
</head>   
<body>
<h1>Cascading Dropdown Examples</h1>
<form name="form1" id="form1" action="/action_page.php">
Type: <select name="Type" id="Type">
    <option value="" selected="selected">None</option>
  </select>
  <br><br>
Case Reason: <select name="Case_Reason" id="Case_Reason">
    <option value="" selected="selected">None</option>
  </select>
  <br><br>
  <input type="submit" value="Submit">  
</form>
</body>
</html>
I expect that if I select the value "1" from Type dropdown field, I should get the values "a,b,c" in Case Reason dropdown field. And if I select the value "2" from Type dropdown field, I should get the values "d,e,f,g,h" in Case Reason dropdown field
 
    