1

I am having trouble with an input I'm trying to get the input of quantity then I have a onClick event that execute the function

 <input type="number" name="quantity" min="1" max="10" value={item.quantity}  className="form-control"/>



 UpdateItem: function(_id) {
                $.ajax({
          url: 'http://localhost:3000/update/' + _id,
          type: 'PUT',
          data:"",
          success: function(result) {
              window.location.reload();
          }
        });
                  }

how do i get a new value on input value is al value={item.quantity} is always number that can't be changed?

1
  • need more context to understand what you are trying to do Commented Mar 10, 2016 at 2:46

1 Answer 1

1

We can use refs to access the DOM node itself, from which we can obtain the value.

http://codepen.io/mikechabot/pen/QNNRyp?editors=0011

Component

class Example extends React.Component {
  updateItem() {
    const input = this.refs.myInput;
    console.log(input.value);
  }
   render() {
        return (
          <div >
            <input ref="myInput" type="number" />
            <button onClick={() => this.updateItem()}>Log Value</button>
          </div>
        )
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.