My form has a table structure in HTML as shown below:
<tr>
<td>Quotation Category<span class="required" style="color: red">*</td>
<td>
<div class="form-group col-md-9">
<select name="quotation_category" class="form-control" style="width: 80%;" id="quotation_category">
<option value="">Pilih Kategori</option>
<option value="konvensional">Konvensional</option>
<option value="syariah">Syariah</option>
</select>
</div>
</td>
<td class="ujroh-style">Ujroh<span class="required" style="color: red">*</span>
</td>
<td class="ujroh-style">
<div class="form-group col-md-9">
<input type="number" class="form-control" id="ujroh" name="ujroh">
</div>
</td> </tr>
This is the javascript I have written:
document.querySelector('#quotation_category').addEventListener('change', () => {
const select_value = document.querySelector('#quotation_category').value
if (select_value === "konvensional") {
document.getElementsByClassName('.ujroh-style').style.display = "none"
} else if (select_value === "syariah") {
document.getElementsByClassName('.ujroh-style').style.display = "revert"
}
})
I need assistance with making it so that when 'konvensional' is selected, Ujroh option appears. And when 'syariah' is chosen, then the Ujroh option disappears. How can I achieve this?
NOTE
The code above is resulting in the following error:
Uncaught TypeError: Cannot set properties of undefined (setting 'display')
at HTMLSelectElement.<anonymous>