Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. const React = require("react");
  2.  
  3. class WishlistForm extends React.Component {
  4. constructor(props) {
  5. super(props);
  6.  
  7. this.state = {name: "", wish: "", priority: 1};
  8.  
  9. this.handleSubmit = this.handleSubmit.bind(this);
  10.  
  11. this.handleName = this.handleName.bind(this);
  12. this.handleWish = this.handleWish.bind(this);
  13. this.handlePriority = this.handlePriority.bind(this);
  14. }
  15.  
  16. handleSubmit(event) {
  17. this.props.send(this.state);
  18. event.preventDefault();
  19. }
  20.  
  21. handleName(event) {
  22. this.setState({name: event.target.value});
  23. }
  24.  
  25. handleWish(event) {
  26. this.setState({wish: event.target.value});
  27. }
  28.  
  29. handlePriority(event) {
  30. this.setState({priority: event.target.value});
  31. }
  32.  
  33. render() {
  34. return (
  35. <form onSubmit={this.handleSubmit}>
  36. <input id="name" onChange={this.handleName} />
  37. <textarea id="wish" onChange={this.handleWish}></textarea>
  38. <select id="priority" value={this.state.priority} onChange={this.handlePriority}>
  39. <option value={1}>1</option>
  40. <option value={2}>2</option>
  41. <option value={3}>3</option>
  42. <option value={4}>4</option>
  43. <option value={5}>5</option>
  44. </select>
  45. </form>
  46. );
  47. }
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement