question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how get more value from onSubmit ?

See original GitHub issue

hello, sir, long time no see, sorry, I bothering your time again… want to ask about the results of the form submit,

[{"text_input_207D331C-0EAF-4D63-AD42-EDFAA74268F5":"Rice","text_input_2E5BAE90-AB31-4800-91C2-8A1858CC1DF9":"1kg"}]

can it be edited and added some results from the submit form, because for now the data obtained is only the name and value,

how do I want to get like a label and others?

thank you

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Kihocommented, Jul 31, 2019

In constructor of demobar.jsx

constructor(props) {
    super(props);
    this.state = {
      data: [],
      previewVisible: false,
      shortPreviewVisible: false,
      roPreviewVisible: false,
    };
    
    // bind submit event handler to this.
    this._onSubmit = this._onSubmit.bind(this);
    const update = this._onChange.bind(this);
    ElementStore.subscribe(state => update(state.data));
  }

In _onSubmit method, you can find form data from state.

  _onSubmit(data) {
    console.log('this.state.data', this.state.data);
    console.log('onSubmit', data);
    // Place code to post json data to server here
  }
0reactions
mike1011commented, Sep 13, 2020

In constructor of demobar.jsx

constructor(props) {
    super(props);
    this.state = {
      data: [],
      previewVisible: false,
      shortPreviewVisible: false,
      roPreviewVisible: false,
    };
    
    // bind submit event handler to this.
    this._onSubmit = this._onSubmit.bind(this);
    const update = this._onChange.bind(this);
    ElementStore.subscribe(state => update(state.data));
  }

In _onSubmit method, you can find form data from state.

  _onSubmit(data) {
    console.log('this.state.data', this.state.data);
    console.log('onSubmit', data);
    // Place code to post json data to server here
  }

both… data and this.state.data confused me but now it helped. Great work Kiho. I love you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing option value to onSubmit? - javascript - Stack Overflow
Passing option value to onSubmit? · You should add an onChange event to the select element as well, and change the value of...
Read more >
How to Get All Form Values on Submit in React - Webtips
We have one useState hook that will store all form values. This is updated with an onChange handler on the inputs that sets...
Read more >
ClientScript - onSubmit() - How to get value of a - ServiceNow
I am creating onSubmit client script and need to access of the reference field's table field value...I tried it by dotwalking but it...
Read more >
useForm - handleSubmit - React Hook Form
This function will receive the form data if form validation is successful. Props. Name, Type, Description. SubmitHandler, (data: Object, e?: Event) ...
Read more >
Get input values on Form submit in React | bobbyhadz
To get input values on form submit in React, store the values of the input fields in state variables. Set the `onSubmit` prop...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found