This example will repopulate the category menu depending on the selected type
<html>
<head>
<title>Sample</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type='text/javascript'>
// array of categories for each type
var cat_types = JSON.parse('{"A":{"1":"Cat 1","2":"Cat 2","3":"Cat 3"},"B":{"4":"Cat 4","5":"Cat 5","6":"Cat 6"},"C":{"7":"Cat 7","8":"Cat 8","9":"Cat 9"}}');
$().ready(function() {
// populate type menu
$.each(cat_types, function(k,v) {
$("#type").append($("<option>", {"val":k, "text":k}))
})
// when type selected, populate cat menu
$("#type").change( function() {
$("#cat").html("<option value=''> - select category -</option");
var type = $(this).val()
$.each(cat_types[type], function(k, v) {
$("#cat").append($("<option>", {"val":k, "text":v}))
})
})
})
</script>
<style type='text/css'>
</style>
</head>
<body>
<form>
Type <select name='type' id='type'>
<option value=""> - select type -</option>
</select>
<br><br>
Cat <select name='cat' id='cat'></select><br>
</form>
</body>
</html>