0

I have problem about showing query result

I have table where there are atributes. The atributes are type, trait, and tariff.

In html, I have 2 select option which fetch with type and trait, and then I have textbox tariff which is empty.

HTML:

<select class="custom-select" id="type" name="type">
       <option value="">Pilih Tipe Barang</option>
       <option value="Tipe 1">Tipe 1</option>
       <option value="Tipe 2">Tipe 2</option>
</select>

<select class="custom-select" id="trait" name="trait">
       <option value="">Pilih Sifat Barang</option>
       <option value="Sifat 1">Sifat 1</option>
       <option value="Sifat 2">Sifat 2</option>
</select>

<input class="form-control" type="text" id="tariff" name="tariff" placeholder="Tarif Bea Penjual">

What I want is when I select type option and trait option, javascript change the value of textbox tariff from the table that I have made it.

I think it's need querying in tag <script> (" SELECT tariff WHERE type = 'type value' AND trait = 'trait value' ").

But I don't know how to make that.

Please help and thank you very much.

theduck
  • 2,589
  • 13
  • 17
  • 23
  • well you need to start by processing the form first, get the user input and make database query, fetch the results and select the appropriate next dropdown. some people call this as _cascading dropdown_ – Kevin Oct 14 '19 at 02:01
  • i have done about cascading dropdown, when i select type option, the select option trait will show the dropdown which link with the selected type option. but i don't know how to do that to textbox. – Muhammad Al Hafidhi Oct 14 '19 at 02:13

1 Answers1

0
  1. add onChange event for id='trait', check out this question on stackoverflow
  2. use the value of id='trait' to get some data you need from db.
  3. update your <input > value, check this article