I have a simple HTML Select, When the user enters the data in the text box if the data entered is Less than some percentage this HTML Select is displaed else it is hidden. I want to add search to it. I tried Select2, but Couldn't implement correctly. Need help The code is as follows
<select name="reason" id="reason#getProdInfo.currentRow#" style="display: none">
<option>--</option>
<option>Line feeding not available</option>
<option>WIP not available</option>
<option>Absenteeism issue</option>
<option>Operator on other operation issue</option>
<option>Reworking due to high DHU</option>
<option>Re-check</option>
<option>Operator training issue</option>
<option>Machine out of order</option>
<option>Operator low efficiency</option>
<option>Trolley not available</option>
<option>Line feeding late arrived</option>
<option>Operator working on extra work</option>
<option>Operator late arrived</option>
<option>Engineering Support not available </option>
</select>
The JS:
$('#prods1').on('focusout', function(){
var element1 = document.getElementById("prods1").value;
var element2 = document.getElementById("trgt").value;
var calc = (element1/element2)*100
if (calc<70){
$("#reason1").show()
}else{
$("#reason1").hide()
}
});
Someone please correct me if I'm wrong here, but perhaps using a ternary for conditionally rendering the select would be easiest and simplest solution to decide if the HTML element renders?
{userInput.length > 0
? <select name="reason" id="reason#getProdInfo.currentRow#" style="display: block">
: <select name="reason" id="reason#getProdInfo.currentRow#" style="display: none">
}