0

I have no idea how to fix this thing have been spent more than an hours to solve this problem but none of the solution fix this

So i have a combo box (Select tag element) which i would like to change the value when a modal box is opened.

I have already implement defaultValue to set the value of the combobox but it won't change. However on other input such as the notes / amount it can get the defaultValue and set it to the element.

I have try to debug the this.currState.deposit_type_id and i get the right value

But in fact it won't change

it always refer to the default value

I have made several type of this thing but none of them has ever had this bug

Here's the screenshot for the code and the image

These are the code to pass the data from parent's component, and deposit type for all the value i will put on the combo box

This is the code to pass the data from parent's component, and deposit type for all the value i will put on the combo box

enter image description here

This is the code that i used for set the default value when the modal box is opened

enter image description here

This is the result, it supposed to choose "Kas Besar", yet it choose "Deposit Type" instead

Jasson Harsojo
  • 237
  • 1
  • 6
  • 15
  • Possible duplicate of [How to get selected value of a dropdown menu in ReactJS](https://stackoverflow.com/questions/29108779/how-to-get-selected-value-of-a-dropdown-menu-in-reactjs) – Hemerson Carlin Nov 12 '17 at 10:31
  • @mersocarlin yea i know bout that thing, i have already implement that, but the dropdown itself won't change – Jasson Harsojo Nov 12 '17 at 15:04

1 Answers1

0

Not sure as I am not able to try it now but you could try to add your value argument for input's html like this:

value={ this.state.currData && this.state.currData.deposit_type_id  }

But it would be better to get currData from props. So this.props.currData.

Andrija Ćeranić
  • 1,633
  • 11
  • 14