I have 2 dropdown lists 1 is populated from the user making selections, the other is populated from the database but the second list gets filtered based on the selection of the first one.
The second list has values coming from the database and when an option is selected from the first dropdown, the code is supposed to check the text of the selection and populate the second list based on the value attached to the text selection
for example: Chromatography-Protein A has a value of 1, I want to filter the process parameters that have a value of 1 and display them.
this is what I have tried so far:
HTML:
<select class="form-control form-control-sm" onchange="unitChange(this)" id="unit-operation">
<option selected disabled value="default">Select</option>
<option>Chromatography-Protein A</option>
<option>Chromatography-Mixed Mode</option>
<option>Yes</option>
<select class="form-control form-control-sm" id="processparameter">
<option selected= "selected" value="default">Select Process Parameter</option>
{% for pp in pp %}
<option value="{{pp.unitoperation_id}}">{{pp.processparameter_name}}</option>
{% endfor %}
</select>
<div class="p-3"></div>
JAVASCRIPT:
$(document).ready(function() {
var options = $("#processparameter").html();
$("#unit-operation").change(function(e) {
var text = ($(this).find("option:selected").text());
alert(text);
$("#processparameter").html(options);
if(text === "Chromatography-Protein A"){
}
});
});